Android AppShortCuts for specific launcher icons

25 Views Asked by At

I have 2 activities which has launcher icons as below. ActivityOne has no shortcuts & ActivityTwo has 3 AppShortcuts.

I want to programatically add dynamic shortcuts on ActivityOne, for which i was using java code as below. In some devices in release version these shortcuts are being appended to the ActivityTwo.

Is there any way to tell that these AppShortcuts are for ActivityOne? Referred android documentation, but no luck. https://developer.android.com/develop/ui/views/launch/shortcuts/managing-shortcuts https://developer.android.com/reference/android/content/pm/ShortcutManager#setDynamicShortcuts

<!--AndroidManifest.xml-->
<activity
    android:name="com.avrapps.hello.ActivityOne"
    android:label="@string/label_one"
    android:icon="@mipmap/label_two"
    android:launchMode="singleTask"
    android:theme="@android:style/Theme.NoDisplay"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name="com.avrapps.hello.ActivityTwo"
    android:label="@string/label_two"
    android:icon="@mipmap/label_two"
    android:launchMode="singleTask"
    android:theme="@android:style/Theme.NoDisplay"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
</activity>

<!--PushNoticationService.java-->

final ShortcutManager shortcutManager = mContext.getSystemService(ShortcutManager.class);
shortcutManager.setDynamicShortcuts(buildAppShortcutsList());

0

There are 0 best solutions below