在Nougat 7.1.1中点击应用快捷方式时,应用未安装错误 [英] App isn´t installed error when tapping app shortcut in Nougat 7.1.1

查看:105
本文介绍了在Nougat 7.1.1中点击应用快捷方式时,应用未安装错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向现有应用添加静态应用快捷方式时遇到一些问题。我遵循了 https://developer.android.com/guide/topics/ ui / shortcuts.html 并显示快捷方式,但是当我点击它时,它不会启动活动,而是显示一条吐司消息: 未安装应用

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>

这是shortcuts.xml文件:

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>

我已经仔细检查过,目标活动的全限定名称为 com。 mypackage.activities.NewActivity 可以。

I´ve already double checked and the target activity full qualified name com.mypackage.activities.NewActivity is ok.

预先感谢!

推荐答案

如果在build.gradle中设置了不同的 productFlavors ,则应确保 android:targetPackage 应用程序ID android:targetClass 应包含程序包名称。

If you set the different productFlavors in build.gradle, you should make sure android:targetPackage is application id, android:targetClass should include package name.

例如:

<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'
        ...
    }
}

在这里,对于您的内部版本,targetPackage应该为 com.example.app.internal ,targetClass应该为 com.example.app.MainActivity

in here for your internal version, targetPackage should be com.example.app.internal, targetClass should be com.example.app.MainActivity

这篇关于在Nougat 7.1.1中点击应用快捷方式时,应用未安装错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆