dpa99c / phonegap-launch-navigator

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows
369 stars 129 forks source link

'user_select' not working on Android #273

Open AmineMansouriLondon opened 2 years ago

AmineMansouriLondon commented 2 years ago

Attempting to launch navigation with user_select throws 'No supported navigation apps are available on the device' even though 'getAppsForPlatform('android')' displays a whole list of apps including 'user_select'. If a specific app is used, the maps opens fine but user_select doesn't open at all, just throws the error.

Not sure why this is happening but could it be a permissions issue? I believe it was working fine before the move to target SDK 30+.

Plugin version: 4.7.0

Tested on Ionic 2.

AmineMansouriLondon commented 2 years ago

For anyone that comes across this issue, it's a permissions problem when targeting Android 11+. Adding: <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <queries> <intent> <action android:name="android.intent.action.SEND" /> <data android:mimeType="*/*" /> </intent> </queries>

fixes the issue. Have a look here: Android 11 behaviour changes: https://developer.android.com/about/versions/11/behavior-changes-11

Query/Intent guide: https://developer.android.com/guide/topics/manifest/queries-element

List of permissions: https://developer.android.com/reference/android/Manifest.permission

F-JJTH commented 2 years ago

Thanks you for this solution, it works ! To be more precise, we must edit config.xml file like this :

<?xml version='1.0' encoding='utf-8'?>
<widget defaultlocale="fr" id="..." version="..." xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>...</name>
    <description>...</description>
    <author email="..." href="http://ionicframework.com/">...</author>
    <content src="index.html" />
    ...
    <platform name="android">
        <config-file parent="/manifest" target="app/src/main/AndroidManifest.xml">
            <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
            <queries>
                <intent>
                    <action android:name="android.intent.action.SEND" />
                    <data android:mimeType="*/*" />
                </intent>
            </queries>
        </config-file>
        ...
    </platform>
</widget>
elenche commented 1 year ago

If anyone is using this plugin with Capacitor: you can directly edit AndroidManifest.xml since you probably don't have a config.xml file.

Copy the following code in between the manifest tags:

<queries>
    <package android:name="com.google.android.apps.maps" />
    <intent>
        <action android:name="android.intent.action.SEND" />
    </intent>
    <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="geo" />
    </intent>
</queries>

Pictured: image