stati c ярлык android не отображается - PullRequest
1 голос
/ 14 января 2020

Я пытаюсь добавить ярлык в свое приложение, но когда я делаю длинный щелчок, я не вижу его.

Я дважды проверил идентификатор своего приложения, а также активность.

Вот что я пытаюсь.

Мой ярлык. xml:

  <shortcut
    android:shortcutId="conso"
    android:enabled="true"
    android:icon="@drawable/ic_budgeting"
    android:shortcutShortLabel="@string/shortcut_conso_short"
    android:shortcutLongLabel="@string/shortcut_conso_long"
    android:shortcutDisabledMessage="@string/shortcut_conso_dissable_message">
    <intent
        android:action="android.intent.action.VIEW"
        android:targetPackage="com.****.stubs_dev.debug"
        android:targetClass="com.******iviConsoActivity" />
    <!-- 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. -->

</shortcut>

в манифесте я добавляю

в приложение и в активность, я добавляю также android: exported = "true"

что не так с моим кодом?

РЕДАКТИРУЙТЕ здесь мой манифест

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="****">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />



<application
    android:name="....."
    android:icon="@mipmap/..."
    android:label="@string/app_name"
    android:networkSecurityConfig="@xml/network_security_config"
    android:resizeableActivity="false"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:replace="icon">

....

   <!-- Shortcuts-->
    <meta-data android:name="android.app.shortcuts"
        android:resource="@xml/shortcuts" />
</application>

Моя декларация активности:

   <activity
        android:name=".****onsoActivity"
        android:screenOrientation="portrait"
        android:exported="true"
        android:theme="@style/AppTheme.NoActionBar"
        >
        <meta-data android:name="android.app.shortcuts"
            android:resource="@xml/shortcuts" />
    </activity>

1 Ответ

2 голосов
/ 14 января 2020

Убедитесь, что ваше xml имя shortcuts.xml, затем убедитесь, что вы добавляете shortcuts.xml в Активность запуска, которая имеет фильтры намерений android.intent.action.MAIN и android.intent.category.LAUNCHER. Давайте предположим, что это MainActivity тогда это будет выглядеть так

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