Launching Google Maps Directions via an intent on Android

后端 未结 15 1622
小鲜肉
小鲜肉 2020-11-22 03:46

My app needs to show Google Maps directions from A to B, but I don\'t want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this

15条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 04:28

    This is what worked for me:

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("http://maps.google.co.in/maps?q=" + yourAddress));
    if (intent.resolveActivity(getPackageManager()) != null) {
       startActivity(intent);
    }
    

提交回复
热议问题