java读取值并通过安卓中的不同应用程序共享
我在通过共享意图共享数据方面有问题。以下是通过不同应用程序共享数据的代码
btnshare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sharingIntent = new Intent(安卓.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "The Langitude: "+longi+"The Latitude:"+lati;
sharingIntent.putExtra(安卓.content.Intent.EXTRA_SUBJECT,value);
sharingIntent.putExtra(安卓.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
}
});
它只是一个按钮,用于共享。但现在的问题是,在这种情况下,我希望共享一些值(我从textview获得的lati,longi)。如何将该值传递给共享操作的消息体
这里的信息是“[lati”和“longi”值的来源,它们属于不同的方法,但属于同一类
private void getLocation() {
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
Log.d("Location:", location.toString());
double lati =location.getLatitude();
double longii=location.getLongitude();
double alt=location.getAltitude();
txt_lati.setText("" +lati);
txt_longi.setText(""+longii);
return;
}
这是lati和longi所属的方法。现在我的问题是如何通过共享提示符共享纬度(lati)和经度(longi)值?我的意思是,我如何才能共享这两个特定的数据?仅供参考,如果我打算以这种方式分享,那么价值就不存在了。类似v7的东西。appcompact消息正文中填充的那种文本
# 1 楼答案
你需要将你的第一个应用程序活动意图作为行动意图
就像
您可以从另一个应用程序调用它