问题
I need to share location from my app using the share intent activity, I have gone through some examples and know how to implement share intent. However I am stuck at setType. I need my application to share location details as well the users location on a map.
By the way i copied a users code with a very similar question"no offence"
Any assistance would be really appreciated.
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"));
回答1:
Here is the code to fire an intent to the map with a location:
String uri = "geo:" + latitude + ","
+longitude + "?q=" + latitude
+ "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(uri)));
回答2:
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"));
回答3:
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..."));
来源:https://stackoverflow.com/questions/12668551/share-location-with-share-intent-activity