Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to dynamically change an app icon like Calendar app does?

I wanna create an Android application, and I want to dynamically and automatically update the app icon similarly to how the calendar icon updates on a user's homescreen.

The calendar changes its icon for each day showing day of month's number. There is also an Alarm clock app which changes its icon setting the current time, in other words, changing every minute.

That isn't a widget, but a real app icon. Then it must have a way to do so. How can I do it in my app?

like image 311
Lennon Spirlandelli Avatar asked Jan 04 '16 13:01

Lennon Spirlandelli


People also ask

Can we change app icon dynamically in IOS?

The setAlternateIconName method is used to change the App Icon to its primary icon or to one of its alternate icons. If alternateIconName is nil then the default App Icon will be used. Finally, alternateIconName returns the name of the alternate icon currently used, or nil if the default icon is used.

Can I change app icon dynamically Android?

This feature can be used when we have an app for different types of users. Then as per the user type, we can change the App Icon Dynamically.

Can app icons be changed?

Press and hold the app icon until a popup appears. Select “Edit”. The following popup window shows you the app icon as well as the application's name (which you can also change here). To choose a different icon, tap on the app icon.

What app can i use to change the icon of an app?

Shortcut Maker works well for this, as it's one of the best Android shortcut apps. X Icon Changer is another option, but it's not as intuitive and has annoying ads. Open Shortcut Changer, then choose Apps to create a new app shortcut.


1 Answers

Whatever your home screen is has special hooks for whatever your calendar app is and whatever your alarm clock app is. In general, apps cannot update their icons.

What do you mean by hooks?

For example, Samsung can ship a Samsung calendar app on Samsung devices. Samsung's home screen on those same Samsung devices can have special rules for rendering an icon for Samsung's calendar app, rules that involve showing the day of the month. This is because Samsung wrote the home screen. If you install a third-party home screen, it may not do the same thing. After all, I can write a home screen in an hour or so, and I feel quite confident that I don't have to do anything special for Samsung's calendar app.

There's nothing stopping Samsung from exposing some sort of API to allow developers to hook into Samsung's home screen and notify it about this sort of thing. Whether Samsung intends for third parties to use that API, or whether it is somebody hacking into how Samsung does it for their own apps, I can't say.

(BTW, I am citing Samsung here as a possible example -- I don't know that they actually have this sort of feature, and if so on which devices they have it)

I seem to recall that somebody has a GitHub project that tries to wrap the proprietary APIs of various home screens. IIRC, some supported capabilities included either replacing the app icon or adding a badge (e.g., unread message count). However:

  • Only a small percentage of devices will support those proprietary APIs

  • Undocumented and unsupported APIs, discovered through reverse-engineering apps, are subject to change and may break in unexpected ways

I am quite certain that there is nothing in the Android SDK that supports dynamic app icons. The only thing that I know of, that people have tried, is using <activity-alias> to have N different "activities", all pointing to the same implementation, but having different icons. Using PackageManager and setComponentEnabledSetting(), the app disables the old launcher alias and enables a different one, in hopes that home screens will pick up on this and show the new icon. A few do. Others only would find out about the change on a reboot.

To flip the problem around, I can write a home screen. Perhaps I want to offer some way for apps to change their icons on the fly, even though there are no standards for it. Perhaps I don't. Perhaps I do not intend to use icons at all, as my home screen is optimized for the visually impaired, and so it is using text-to-speech and hardware key input. It's my home screen implementation, and I can do what I want.

like image 146
CommonsWare Avatar answered Sep 17 '22 17:09

CommonsWare