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???
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.
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”.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With