Статические закрепленные ярлыки на значке моего приложения появляются, но нажатие на них не запускает запланированное действие? - PullRequest
0 голосов
/ 22 ноября 2018

Я пытаюсь реализовать ярлыки статических значков Oreo в моем проекте. Ниже приведен мой файл shortcuts.xml , который присутствует в каталоге xml моего проекта.Я добавил правильные строки в файл strings.xml resorce.Существует два ярлыка: один переводит пользователя на AboutActivity , а другой - на ShareActivity .

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:shortcutId="About"
        android:enabled="true"
        android:icon="@drawable/about_icon"
        android:shortcutShortLabel="@string/shortcut_short_label"
        android:shortcutLongLabel="@string/shortcut_long_label">
            <intent
                android:action="android.intent.action.VIEW"
                android:targetPackage="com.example.shortcuts"
                android:targetClass="com.example.shortcuts.ui.activity.AboutActivity" />
    </shortcut>
    <shortcut
        android:shortcutId="Pi Power Share"
        android:enabled="true"
        android:icon="@drawable/power_share_icon"
        android:shortcutShortLabel="@string/shortcut_short_label1"
        android:shortcutLongLabel="@string/shortcut_long_label1">
            <intent
                android:action="android.intent.action.VIEW"
                android:targetPackage="com.example.shortcuts"
                android:targetClass="com.example.shortcuts.ui.activity.ShareActivity" />
    </shortcut>
</shortcuts>

Я также добавил необходимые метаданные в свои приложения LAUNCHER и MAIN в файле Manifest.xml .Ниже приведен фрагмент файла Manifest.

<activity
        android:name=".ui.activity.SplashActivity"
        android:label="@string/app_name"
        android:theme="@style/AppBaseTheme.NoActionBar.TranslucentStatus">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <data android:scheme="myapp" />

            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
        <meta-data android:name="android.app.shortcuts"
            android:resource="@xml/shortcuts" />
    </activity>

Приложение собирается без ошибок.Я могу установить приложение, и ярлыки отображаются, как и ожидалось.Однако нажатие на ярлыки не запускает желаемое действие.Чего мне не хватает?

...