androidandroid-intentandroid-location

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")); 

Solution

  • 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)));