Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change APP icon dynamically in android

Tags:

android

I have tried below code in order to change application icon dynamically but no use.

Manifest:

<uses-permission android:name="com.android.launcher.action.INSTALL_SHORTCUT"/>

Class:

Intent myLauncherIntent = new Intent();
myLauncherIntent.setClassName("your.package.name", "YourLauncherActivityName");
myLauncherIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, myLauncherIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Application Name");
intent.putExtra
       (
        Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
        Intent.ShortcutIconResource.fromContext
                                    (
                                         getApplicationContext(),
                                         R.drawable.app_icon
                                    )
       );
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");

getApplicationContext().sendBroadcast(intent);

I need to show counter on app icon whenever any incoming message comes to my app like gmail app. So How can i get app icon & set icon dynamically in android???

like image 958
Yella Goud Avatar asked Jun 17 '13 11:06

Yella Goud


People also ask

How do I make adaptive icons on Android?

Add your adaptive icon to your app xml , create alternative drawable resources in your app for backward-compatibility with Android 8.0 (API level 26). You can then use the <adaptive-icon> element to define the foreground, background, and monochromatic layer drawables for your icons.

Can Android users change app icons?

Changing individual icons on your Android smartphone* is fairly easy. Search the app icon you want to change. Press and hold the app icon until a popup appears. Select “Edit”.

Can you change icons in app drawer?

You can use Shortcut Maker to customize app icons and names on any device. Go to Settings > Themes to download and apply icon packs on Samsung devices. You can download and install custom icons via Google Play Store on any Android device. You may need to install a launcher to change app icons.


1 Answers

You cannot modify the app icon dynamically. Gmail does not modify the app icon dynamically.

A home screen -- being the app that actually displays these things -- could elect to apply a badge to certain app icons. And you can create an app widget that looks like an icon with a badge.

like image 187
CommonsWare Avatar answered Oct 16 '22 16:10

CommonsWare