1

First of all I read the other solution attempts on here but their fixes don't work for me for some reason.

My shortcut XML looks like this:

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:enabled="true"
        android:icon="@drawable/ic_shortcut_tinted"
        android:shortcutId="shortcut"
        android:shortcutLongLabel="@string/shortcut_longLabel"
        android:shortcutShortLabel="@string/shortcut_shortLabel"
        android:shortcutDisabledMessage="@string/shortcut_disabledMessage">
        <intent
            android:action="android.intent.action.VIEW"
            android:targetClass="de.example.exampleApp.exampleClass"
            android:targetPackage="de.example.exampleApp" />
        <categories android:name= "android.shortcut.example" />
    </shortcut>
</shortcuts>

My relevant code in the AndroidManifest file looks like this:

<activity
            android:name=".common.ui.activities.MainActivity"
            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>

I made sure that in my build.gradle the ApplicationId is de.example.exampleApp

I have no clue what else to do. If it is relevant in any way I test my app on the Genymotion Emulator instead of a real device.

hullunist
  • 1,117
  • 2
  • 11
  • 31

1 Answers1

0

Okay as it seems I overlooked the information that you can only make shortcuts to Activities (e.g. android:targetClass has to be an Activity)

As a solution I used a kind of hacky(?) solution which you can see here

hullunist
  • 1,117
  • 2
  • 11
  • 31