Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Im a newbie here in android programming. Here is my simple code just to launch the intent with the given coordinates. The problem is, how to get my current location and use it to show my current location whenever the google map intent starts.

public void viewroute (View view)
{
    if  (view.getId()==R.id.ViewRoute)
      {
        Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("geo:9.8500,124.1435"));
        startActivity(intent);
      }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
544 views
Welcome To Ask or Share your Answers For Others

1 Answer

you have to try like this

String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);

for more information visit here : https://developer.android.com/guide/components/intents-common.html#Maps

if you need with direction follow this

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
    Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);

Hope it will help you :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...