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???
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.