android - How to Avoid Multiple Options Of Map -




my device have both waze , googlemap. in app want open google map when click button. open waze app when click other button. problem show options of waze , googlemap.how can avoid option selection , go direct map curresponding button click.

i used code open googlemap is,

intent intent = new intent(android.content.intent.action_view,                     uri.parse("http://maps.google.com/maps?saddr=" + currentlocation.getlatitude() + "," + currentlocation.getlongitude() + "&daddr=" + destination.getlatitude() + "," + destination.getlongitude()));             startactivity(intent); 

i used code open waze app is,

string uri = "geo:" + currentlocation.getlatitude() + ","                         +currentlocation.getlongitude() + "?q=" + destination.getlatitude()                         + "," + destination.getlongitude();                 intent intent = new intent(android.content.intent.action_view,                         uri.parse(uri));                 startactivity(intent); 

you can force open application using package filter, please find below

  private void openmap(string apppackagename, string url) {         boolean found = false;         intent intent = new intent(intent.action_view);         intent.setdata(uri.parse(url));          list<resolveinfo> resinfo = getpackagemanager().queryintentactivities(intent, 0);         if (!resinfo.isempty()){             (resolveinfo info : resinfo) {                 if (info.activityinfo.packagename.tolowercase().contains(apppackagename) ||                         info.activityinfo.name.tolowercase().contains(apppackagename) ) {                      intent.setpackage(info.activityinfo.packagename);                     found = true;                     break;                 }             }             if (!found)                 return;              startactivity(intent.createchooser(intent, "select"));         }     } 

and usage

private string packagename; if(googlemapclicked) {    packagename = "com.google"; }else{    packagename = "com.waze"; } openmap(packagename,"http://maps.google.com/maps?saddr=" + currentlocation.getlatitude() + "," + currentlocation.getlongitude() + "&daddr=" + destination.getlatitude() + "," + destination.getlongitude()); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -