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

Writing an app which can be updated across devices [closed]
yaw pitch roll of -Z axis from the android sensors
Starting an Activity First in Android?
How to darken a screen in android?
Android storing relative high amount of string_array in strings.xml
Android ListView with Style to the elements issue; after scroll style changes automatically
how can we print The name of activity in logcat
Create user profiles on the android device like we have accounts on PC
Android : Refresh View location after TranslateAnimation?
how to customise side indexer in android?
Store private data on external storage
issues in spinner Android?
I can't write into the EditText, it disappears when i try to write something, its because the getView() is called when i modify the data
How to cut a dynamic string [closed]
How to make a blocking Android HttpRequest
Android handler skip/jump a second

Categories

HOME
algorithm
phantom-dsl
oracle12c
porting
deep-learning
c++11
nunit
jax-rs
mjml
solver
devise
entity-framework-core
web-hosting
maxscript
pearson-correlation
modal-dialog
performancepoint
rcloud
octave
datastage
tput
libc
pybossa
cumulocity
do-while
screen-readers
scsi
microsoft-dynamics-nav
google-data-studio
asp.net-mvc-viewmodel
database-connection
windows-xp
backpack-for-laravel
systemtime
imageresizer
errbot
custom-controls
autodesk-designautomation
utorrent
record
git-squash
nohup
sim-card
apns-php
metawidget
comparison-operators
doc
visa
linqpad
sharp-snmp
knime
file-sharing
snapchat
podscms
cup
rackspace-cloud
template-toolkit
swingworker
chromium-os
myspace
beamer
synonym
scaffolding
dimension
respondcms
refinerycms
cda
phpwebsocket
thread-sleep
libvlc
state-restoration
ons-api
android-launcher
sapscript
doctype
wso2greg
dronekit-android
branch-and-bound
ansi
snoop
shopizer
xmltype
procedural-programming
execve
metatrader5
nsmenu
reflector
functional-java
file-not-found
solace-mq
mysql-error-1044
jammer
script#
route-provider
poker
time.h
composite-component
video-codecs
twisted.web
boost-signals
lr
tournament
uipagecontrol
cdonts
twitterizer
svk
resharper-6.0
jqueryform
pos-for-.net
duplex
dojo-dnd

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