I´m having some issues when adding an static app shortcut to an existing app. I followed the steps from https://developer.android.com/guide/topics/ui/shortcuts.html and the shortcut shows up, but when I tap it it doesn't launches the activity, instead it shows a toast message saying: "App isn´t installed".
Here is the relevant section of the manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activities.SplashActivity"
android:noHistory="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>
<activity
android:name=".activities.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".activities.ListActivity"
android:label="@string/title_activity_list"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mypackage.activities.MainActivity" />
</activity>
<activity
android:name=".activities.NewActivity"
android:label="@string/title_activity_new"
android:parentActivityName=".activities.ListActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mypackage.activities.ListActivity" />
</activity>
<application/>
</manifest>
Here is the shortcuts.xml file:
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="shortcut_new_alarm"
android:enabled="true"
android:icon="@mipmap/ic_launcher"
android:shortcutShortLabel="short label"
android:shortcutLongLabel="long label"
android:shortcutDisabledMessage="message">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.mypackage"
android:targetClass="com.mypackage.activities.NewActivity" />
<!-- If your shortcut is associated with multiple intents, include them
here. The last intent in the list determines what the user sees when
they launch this shortcut. -->
<categories android:name="android.shortcut.conversation" />
</shortcut>
<!-- Specify more shortcuts here. -->
</shortcuts>
I´ve already double checked and the target activity full qualified name com.mypackage.activities.NewActivity
is ok.
Thanks in advance!
The Android app not installed error can be combated after resetting app permissions. Go to Settings > Apps > Reset App Preferences/Reset Application Permissions. After this, third-party software can be installed on your device.
Clear the Google Play Store data If cleaning the cache of the Google Play Store and Google Play Services doesn't resolve the issue, try clearing the Google Play Store data: Open the Settings menu on your device. Go to Apps or Application Manager. (This option might differ depending on your device.)
If you set the different productFlavors
in build.gradle, you should make sure android:targetPackage
is application id
, android:targetClass
should include package name.
eg:
<shortcut
android:shortcutId="shortcut_id_xxx"
android:enabled="true"
android:icon="@drawable/shortcut_xxx"
android:shortcutShortLabel="@string/shortcut_xxx">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.example.app.internal"
android:targetClass="com.example.app.MainActivity" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
productFlavors {
internal {
applicationId 'com.example.app.internal'
...
}
}
in here for your internal version, targetPackage should be com.example.app.internal
, targetClass should be com.example.app.MainActivity
Change your android:targetPackage="com.mypackage"
to your application id present in your app/gradle. Hope this will help you.
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