固定快捷方式中奇怪的应用程序图标重复(Android O)

Bar*_*ica 5 java icons android shortcut android-8.0-oreo

我正在为Android O设备(仿真器或物理设备)的应用启动器图标创建固定的快捷方式,并发现了奇怪的行为。我的代码如下所示:

@TargetApi(Build.VERSION_CODES.O)
    private void createPinnedShortcut(Context context) {
        ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
        if (shortcutManager != null) {
            if (shortcutManager.isRequestPinShortcutSupported()) {
                Intent intent= MainActivity.getLaunchIntent(this);
                intent.setAction(Intent.ACTION_VIEW);

                ShortcutInfo shortcut = new ShortcutInfo.Builder(context, "my_shortcut_id")
                        .setShortLabel(context.getString(R.string.my_app_description))
                        .setLongLabel(context.getString(R.string.my_app_long_description))
                        .setIcon(Icon.createWithResource(context, R.mipmap.my_app_icon))
                        .setIntent(intent)
                        .build();
                shortcutManager.requestPinShortcut(shortcut, null);
            } else
                Toast.makeText(context, "Pinned shortcuts are not supported!", Toast.LENGTH_SHORT).show();
        }
    }
Run Code Online (Sandbox Code Playgroud)

一切正常,但是主屏幕上的启动器图标已复制:

应用启动器图标

有一个正常的图标,但是在右下角放置了另一个图标副本(缩小了约30-40%)。

我的图标资源在res/mipmap-*dpi*文件夹中

有什么提示,线索吗?

更新资料

回答评论:

1)AndroidManifest下./build/manifests/debug看起来像:

    <activity
        android:name="ru.ivanovpv.cellboxkeeper.android.MainActivity"
        android:exported="true"
        android:label="@string/cellboxkeeper"
        android:theme="@style/DefaultActivityTheme.Light"
        android:windowSoftInputMode="adjustResize" >
        <layout
            android:defaultHeight="800dp"
            android:defaultWidth="480dp"
            android:gravity="top|end"
            android:minHeight="320dp"
            android:minWidth="240dp" />

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter> <!-- handle cbx files -->
        <intent-filter
            android:icon="@mipmap/cellboxkeeper"
            android:label="@string/cellboxkeeper"
            android:logo="@mipmap/cellboxkeeper" >
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.cbx"
                android:scheme="content" />
        </intent-filter> 
        <!-- receive files from android share intent -->
        <intent-filter
            android:icon="@mipmap/cellboxkeeper"
            android:label="@string/addToCellboxKeeper" >
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <data android:mimeType="*/*" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

2)有不喜欢的任何文件夹:mipmap-*-v26。这是真实apk文件夹的屏幕截图。文件夹中的所有图标都是正常的(没有重复)。

资料夹

还有其他版本吗?

Bar*_*ica 4

我找到了解决方案,关键是属性android:logo

<intent-filter
        android:icon="@mipmap/cellboxkeeper"
        android:label="@string/cellboxkeeper"
        android:logo="@mipmap/cellboxkeeper" >
        <action android:name="android.intent.action.VIEW" />
Run Code Online (Sandbox Code Playgroud)

删除行并android:logo修复重复问题。

希望,有人有时会使用并理解正在发生的事情