I updated Android Studio to support API 25 and implement it in project. I also look for different resources to find right answer on my question, but with no luck. First, I need to say that I test app on Android 6.0.1 with Action and Nova Launcher (but Google apps working).
So, I implemented in AndroidManifest.xml:
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
Created shortcuts.xml in xml - res. There, I enter this:
<shortcut
android:shortcutId="sc1"
android:enabled="true"
android:icon="@drawable/ic_kalendar"
android:shortcutShortLabel="@string/shortcut_kalendar"
android:shortcutLongLabel="@string/shortcut_kalendar_long"
android:shortcutDisabledMessage="@string/message_off">
<intent
android:action="android.intent.action.MAIN"
android:targetClass="com.ips.orto.MainActivity"
android:targetPackage="com.ips.orto" />
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.ips.orto"
android:targetClass="com.ips.orto.kalendar.Kalendar"/>
</shortcut>
<shortcut
android:shortcutId="sc2"
android:enabled="true"
android:icon="@drawable/ic_else"
android:shortcutShortLabel="@string/shortcut_else"
android:shortcutLongLabel="@string/shortcut_else_long"
android:shortcutDisabledMessage="@string/message_off">
<intent
android:action="android.intent.action.MAIN"
android:targetClass="com.ips.orto.MainActivity"
android:targetPackage="com.ips.orto" />
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.ips.orto"
android:targetClass="com.ips.orto.else.Something"/>
</shortcut>
I try removing android: in attributes, still not working. Also, I add android:exported="true" to Activity which are point to in Shortcuts and I didn't create shortcuts.xml in any special v- bucket.
Does anyone know what I'm doing wrong?
So, I finally find the answer. Catch is very simple. Code:
<activity ...>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts"/></activity>
Means to add meta not only in application part of Mainfest, but also in Activity for which you create definition in shortcuts.xml (for example, if you define shortcut to ThirdActivity, you will add above code to that Activity in Manifest). Also, just chosen activities need this line:
android:exported="true"
and after that it works as supposed to both in Action and Nova Launcher, as well as in Android 7.1 emulator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With