Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange app icon duplication in pinned shortcut (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:

app launcher icon

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

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

Any hints, clues?

Update

Answering to comments:

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

folders

Any other versions?

like image 985
Barmaley Avatar asked Oct 16 '22 10:10

Barmaley


1 Answers

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

Deleting line with android:logo fixes duplication issue.

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

like image 122
Barmaley Avatar answered Oct 20 '22 22:10

Barmaley