回答

2

願這可以幫助你。

實施例: -

btn_click.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     new Handler().postDelayed(new Runnable() { 
      @Override 
      public void run() { 
       Uri gmmIntentUri = Uri.parse("geo:0,0?q="); 
       Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); 
       mapIntent.setPackage("com.google.android.apps.maps"); 
       startActivity(mapIntent); 
      } 
     }, 1000); 
    } 
}); 
2

過去這段代碼中的onclick聽者

String uri = "http://maps.google.com/maps?saddr=" + sourceLatitude + "," + sourceLongitude + "&daddr=" + destinationLatitude + "," + destinationLongitude; 
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 
startActivity(intent); 
+0

怎麼樣sourceLatitude和經度其示值誤差@sagar帕特爾 –

+0

添加位置的緯度和經度 – 2017-04-05 07:04:00

+0

我先生怎麼不知道 –

0

字符串URI = 「http://maps.google.com/maps?saddr=」 + sourceLatitude + 「」 + sourceLongitude + 「& DADDR =」 + destinationLatitude + 「」 + destinationLongitude;

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 

intent.setPackage(「com.google.android.apps.maps」);

startActivity(intent);