Change application name and icon programmatically in Android? - android

Is there any way that the user can choose the application name and launcher icon of my app and set it programmatically?
I want to give the permission to user so that he can rename my application and also change the launcher icon of the app.
Is there any solution to this?

The only thing you can do is to define multiple Launcher Activities with pre-defined icons and labels, and enable/disable them programmatically.
setComponentEnabledSetting (ComponentName componentName, int newState, int flags)

It is not possible to change either of these values easily. You could create new Launcher Icons from inside the app, and then control them easier - like the other answer suggests).
Bottom line, this is not easily done using standard Android framework to the best of my knowledge.

Related

How do you change the nav-bar background (not just color), even when not in foreground?

Background
Somehow the app "Navbar Apps" allows to customize the background of the nav bar, even if it's not in the foreground, and even not just a simple color.
The problem
I thought it's only possible to change the color of it, and only when the app is in the foreground...
I've seen it on some custom roms, even having special effects when music plays, but I didn't know it's possible to customize it even without a custom rom (or root).
The questions
Is it a hack? How do they change, not just the color of the navigation bar, but even set a background image for it (including dynamic one, for battery status) ?
Is it also possible to change other system bars, like the notification bar?
How does it check which app is in the foreground (needed for deciding when to change the color, based on current app, probably)? Is it a new API ? I thought that the API for getting the foreground activity got deprecated and now doesn't help in any way...
The basic setup is quite easy. Making it into an app will take some work.
You'll need to use the Accessibility APIs, along with WindowManager#addView(...).
Is it a hack?
I can't say I like the idea, but its not exactly a hack.
How do they change, not just the color of the navigation
bar, but even set a background image for it (including dynamic one,
for battery status) ?
Since we're adding a View (or ViewGroup), we have a lot more control.
Is it also possible to change other system bars, like the notification bar?
I'll look into this.
How does it check which app is in the foreground (needed for deciding
when to change the color, based on current app, probably)?
You can use Accessibility APIs to listen for Window level changes (AccessibilityEvent) - this will give you the packageName. Use it as you like.
I'll provide you with some pointers:
Manifest:
permission: SYSTEM_ALERT_WINDOW
accessibility service declaration: <service />
Accessibilityservice
Inflate, initialize & add your layout in: onServiceConnected()
I used TYPE_SYSTEM_OVERLAY with WindowManager#addView(...)
Listen for AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED
Override onAccessibilityEvent(AccessibilityEvent); packageName will be available here
Outcome
An example project is hosted here: Link.

Change App Icon And Name From Outside

Is there any way that set the application Icon and Name from an external resource such as an image which embedded inside the assets/ folder in the project?
Or is there any way that let us set icon and name of app without using AndroidManifest.xml file?
Is there any way that set the application Icon and Name from an external resource such as an image which embedded inside the assets/ folder in the project?
No.
Or is there any way that let us set icon and name of app without using AndroidManifest.xml file?
No.
For your activities, you can override the title and/or icon used in the action bar or title bar, if that is your actual objective. However, you cannot change the values used for things like the home screen launcher icon or your app's entry in the application list in Settings.
No it is not possible . You should send an update and things would change in accordance with AndroidManifest.xml .
So what I will suggest is, to send an update
I found the answer. by Using APKtool

Android - change Launcher Icon Language

I want add a settings for language to my app which is independent from system language.
I could manage to change language of anything but the launcher icon is still in system language.
Is it possible anyhow to change that icon language?
Metin
Let's say that you are supporting N languages with this dubious feature.
You will need N entries in your manifest for the launcher activity. Each of those N entries will need an android:label pointing to a string that represents what you want displayed when your app is configured for -such-and-so language. You would then use PackageManager and setComponentEnabledSetting() to disable the old activity and enable the new one.
It is conceivable that you could use one <activity> element and N <activity-alias> elements to achieve your objective, but I am uncertain as to whether you can enable and disable activity aliases.

Dynamically Updating Launcher Icon in Android

I am trying to put a dynamic value in the launcher icon of android, as number of messages will be displayed in the message icon. As the icon is static and initialised before the application starts, Is there any way to achieve this??
For Android Launcher Icon you can't. It is impossible. (Or by Making your own launcher) The only one thing is you have to make a Android-Widget for this purpose. Which looks like a application icon. But it will act as a widget.
Also Make a dynamic launcher icon
simple answer is you can't do it also this question says the same. But there may be advance tricky methods/ways that I'm not aware of.
But you may try and develop widgets that changes dynamically.
You have to design your icon as a selector instead of drawable. Have a look at this.
You cant update because its related to manifest.xml stuff only possible with software upgrade.

how can i set the application icon programmatically android

I know that we can set it through manifest file using android:icon attribute.But how can we set it in java code?
It doesn't make sense to set it programmatically, the launcher has to display the application icon when the application isn't active.
If you take a look at How to change an application icon programmatically in Android?, you will find a comment, which links to this sample code in the Android developer API demos: LaucherShortcuts.
It seams that the Activity can create a LauncherShortcut, which can have a different icon (see function setupShortcut()). If you want the user to select the Icon, you have to display a list of icons when creating the shortcut. But again, it is a shortcut. In the list of application the original icon appears.
I dont think the launcher icon can be set programatically.

Categories

Resources