Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

share location with share intent Activity

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")); 
like image 543
Princewill Obinna Iwuorie Avatar asked Oct 01 '12 06:10

Princewill Obinna Iwuorie


2 Answers

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)));
like image 143
Ankit Thakkar Avatar answered Sep 23 '22 16:09

Ankit Thakkar


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"));
like image 33
darkosj Avatar answered Sep 22 '22 16:09

darkosj