Android – how to prompt the user to select the default navigation application

I have an application that allows users to click on the address to navigate from their current location. Now it opens waze. But now I want users to choose between maps, waze and other installed navigation applications and make a default value

I tried:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(Locale.US, "geo:%.8f,%.8f", latitude, longitude)));
startActivity(Intent.createChooser(intent, "Select an application"));

It lets me choose, but it doesn't start navigation. It's just a classic point on the map. What I want is to open the navigation of any application. For maps, it is:

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

But it won't let users use which application

Is there any way to complete it automatically? If not, what can users choose?

resolvent:

Make intent.setpackage ("com. Google. Android. Apps. Maps"); You are forcing Google maps. Starting with the documentation:

Just delete it:

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
startActivity(mapIntent);

to update:

It seems that waze responded http://maps.google.com Intents, so you can implement the required functions in this way (it doesn't work for icoyote):

Uri gmmIntentUri = Uri.parse("http://maps.google.com/maps?q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
startActivity(mapIntent);

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>