I'm trying to implement app icon shortcut on Android. I followed the documentation but I'm having problem launching the app from the shortcut. Every time I click the app icon shortcut, nothing happens.
Here's the code on my AndroidManifest.xml
file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.package.myapp">
<application
android:name=".MyApp"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar"
android:usesCleartextTraffic="${usesCleartextTraffic}"
tools:ignore="ExportedService,GoogleAppIndexingWarning,UnusedAttribute">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
...
</application>
</manifest>
Here's the shortcuts.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="UnusedAttribute">
<shortcut
android:enabled="true"
android:icon="@drawable/ic_send"
android:shortcutId="send_funds"
android:shortcutLongLabel="@string/LBL_SEND_FUNDS"
android:shortcutShortLabel="@string/BTN_SEND">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="com.package.myapp.MainActivity"
android:targetPackage="com.package.myapp" />
</shortcut>
</shortcuts>