固定快捷方式中奇怪的应用程序图标重复(Android O) [英] Strange app icon duplication in pinned shortcut (Android O)

查看:94
本文介绍了固定快捷方式中奇怪的应用程序图标重复(Android O)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm creating a pinned shortcut of my app launcher icon for Android O device (either emulator or physical device) and found strange behaviour. My code looks like this:

@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();
        }
    }

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

Everything works, but the launcher icon on the home screen is duplicated:

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

There is a normal icon, but on right lower corner it placed yet another copy of the icon (about 30-40% smaller).

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

My icon resources are in res/mipmap-*dpi* folders

有任何提示,线索吗?

更新

回答评论:

1)./build/manifests/debug下的AndroidManifest如下:

1) AndroidManifest under ./build/manifests/debug looks like:

    <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>

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

2) There's not any folder like: mipmap-*-v26. Here's screenshot of folders in real apk. All icons in folders are normal (w/o duplication).

还有其他版本吗?

推荐答案

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

I found solution, key is attribute android:logo:

<intent-filter
        android:icon="@mipmap/cellboxkeeper"
        android:label="@string/cellboxkeeper"
        android:logo="@mipmap/cellboxkeeper" >
        <action android:name="android.intent.action.VIEW" />

android:logo删除行可解决重复问题.

Deleting line with android:logo fixes duplication issue.

希望,有时有人会使用并了解发生了什么

Hope, someone and sometimes will use and understands what's goin on

这篇关于固定快捷方式中奇怪的应用程序图标重复(Android O)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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