android


How to prompt the user to choose default navigation application


I have an app which let the user click on the address to start the navigation from his current position. For now it open Waze. But now I want to let user to choose between maps, waze and other navigation app installed and make one default.
I tried using :
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 let me choose but it not start the navigation, just a classique point on a map. What I want is to open the navigation of any app.
for map it's :
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 does not let the user which application to use.
So is there a way to do that automatically ? if not what can be the alternative to let the user choose ?
Doing intent.setPackage("com.google.android.apps.maps"); you are forcing to use Google Maps. From the documentation:
public Intent setPackage (String packageName)
(Usually optional) Set an explicit application package name that limits the components this Intent will resolve to. If left to the default value of null, all components in all applications will considered. If non-null, the Intent can only match the components in the given application package.
Just remove it:
Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
startActivity(mapIntent);
UPDATE:
It seems that Waze responds to http://maps.google.com Intents, so you can achieve your desired functionality this way (does not 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);

Related Links

How to toast a simple message when you walk into a Geofence?
Need help debugging SSLHandshakeException in Android Nougat
Occluded child view's in LinearLayout in ScrollView
Send frame data of camera (camera2 api) from one phone and display on another phone using WiFi Direct
Android Retrofit Post Issue
Azure Notification Hub no longer accepting GCM API Key
How do I find the version number of the library I am using intellij ant builds for my android application?
FloatingActionButton to launch new activity
GetFieldID fails on Android 4.4 and older
Prevent HorizontalScrollView to be accessed from anywhere on the screen
Android NDK: undefined reference to 'stderr'
Parallax effect in CollapsingToolbarLayout doesn't work anymore in buildToolsVersion “24.0.2”
Android Volley always fails with Proguard
Issues with SKMaps with certain devices
BLE Discover Diffrent Custom Service on OnePlue Device
Android Studio - set build directory globally (per machine)

Categories

HOME
shell
microsoftgraph
turing-machines
c99
datastore
depth
mysql-workbench
components
sitecore
access
aws-cli
scripting
telegram-bot
pearson-correlation
nfs
elasticsearch-5
categorical-data
mxgraph
openbugs
shared-libraries
flatpak
production
babel
href
ember-cli
pimcore
exploit
zxing
short-url
draft-js-plugins
xcode-ui-testing
beautifier
custom-post-type
angular-translate
errbot
turfjs
angularjs-material
android-sugarorm
fiware-cygnus
protein-database
mcustomscrollbar
watchface
strftime
mesosphere
xbmc
yii2-api
user-defined-fields
static-cast
objectscript
django-1.10
flex4.6
neon
beamer
model-associations
simevents
lean
asyncdisplaykit
state-restoration
file-move
roadkill-wiki
forwarding
apache-commons-daemon
fits
infosphere-spl
crowd
rickshaw
cuba
memset
gae-quotas
koala
amslidemenu
jammer
breakout
printdialog
css-reset
superscrollorama
mysql-error-2013
virtual-pc
resource-management
boost-msm
adobe-media-server
mapping-by-code
oracle-enterprise-linux
denied
screen-size
promotion-code
xcelsius
cloudfiles
nhprof
ruby-1.8
folding
web-garden
scrollbars
nstokenfield
burndowncharts
strtod
purepdf
xpsdocument
flvplayback
ifilter

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App