Android 与共享意图活动共享位置

Android 与共享意图活动共享位置,android,android-intent,android-location,Android,Android Intent,Android Location,我需要使用共享意图活动从我的应用程序中共享位置,我已经通过一些示例了解了如何实现共享意图。然而,我被困在setType。我需要我的应用程序共享位置详细信息以及用户在地图上的位置 顺便说一下,我复制了一个用户代码,上面有一个非常类似的问题“没有冒犯” 任何帮助都将不胜感激 Intent intent1 = new Intent(Intent.ACTION_SEND); intent1.setType("text/plain"); intent1.putExtra(Intent.EXTRA_TE

我需要使用共享意图活动从我的应用程序中共享位置,我已经通过一些示例了解了如何实现共享意图。然而,我被困在setType。我需要我的应用程序共享位置详细信息以及用户在地图上的位置

顺便说一下,我复制了一个用户代码,上面有一个非常类似的问题“没有冒犯”

任何帮助都将不胜感激

Intent intent1 = new Intent(Intent.ACTION_SEND); 
intent1.setType("text/plain"); 
intent1.putExtra(Intent.EXTRA_TEXT, "The status update text"); 
startActivity(Intent.createChooser(intent1, "Select prefered Service")); 

以下是使用位置向地图发送意向的代码:

String uri = "geo:" + latitude + ","
                    +longitude + "?q=" + latitude
                    + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW,
                    Uri.parse(uri)));

非常感谢,但这不是我想要的,你的代码打开了谷歌地图。我不想启动谷歌地图,我只需要我的应用程序能够分享我的当前位置,更像谷歌地图分享位置,只是为任何人添加一个注释,让他们使用这个示例并运行它。如果自定义“q”参数,请确保安全地构建Uri:
String Uri=Uri.Builder().scheme(“geo”).appendPath(lat+,“+lng”).appendQueryParameter(“q”,name).build()
您需要使用
Intent.createChooser
打开一个包含所有支持该意图的应用程序的选择对话框。见其他答案。
Double latitude = user_loc.getLatitude();
Double longitude = user_loc.getLongitude();

String uri = "http://maps.google.com/maps?saddr=" +latitude+","+longitude;

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String ShareSub = "Here is my location";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, ShareSub);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, uri);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
    String uri = "https://www.google.com/maps/?q=" + latitude+ "," +longitude ;
    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,  uri);
    startActivity(Intent.createChooser(sharingIntent, "Share in..."));