共享位置与共享意图活动

Pri*_*rie 10 android android-intent android-location

我需要使用共享意图活动从我的应用程序共享位置,我已经通过一些示例并知道如何实现共享意图.但是我被困在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")); 
Run Code Online (Sandbox Code Playgroud)

Ank*_*kar 10

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

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

  • 非常感谢,但这不是我想要的,你的代码打开了谷歌地图。我不想启动谷歌地图,我只需要我的应用程序能够共享我当前的位置,就像谷歌地图共享位置一样 (3认同)

小智 8

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"));
Run Code Online (Sandbox Code Playgroud)