Programmatically change Android application icon and name - android

Basically I just want to be able to programmatically change the application's name and icon
without it reverting to back the originals.
The main way people seem to be doing it is by using an activity-alias
in AndroidManifest.xml, but that seems to need you to use a different
Main package name, I don't want to have another one, I'd like to be able to
use the same one for both.
And, isn't using an activity-alias just going to temporarily change them?
Is there a different way to enable one and disable the other one without having
to use a different package name?
And is there any other reliable way to programmatically change the app icon and name?
It seems like a lot depends on what OS version you are using.
Oh, and not having to add any sketchy permissions if possible.
This on Windows.
Thanks!

Related

Xamarin, Android: Change name of whole app, not just the Label

this might sound like a simple question, but I haven't been able to find a solution to this:
I created an app that I now want to publish, but while debugging, this app had an incorrect name.
Now, ofcourse I can change the namespace and / or label in my MainActivity, so that the app on my phone gets the right name assigned to - but if you check this app under "application" it still has its original name.
Is there anyway how I can change all of my Apps name in like "one click"? I did find a few instances, in which the "old" name still appeared, but changing one led to this app no longer debugging.
I'm using Visual Studio :)
THANKS!
You should change it in the AndroidManifest.xml

Clear Default App ONLY for specific Intent

I know it is possible to clear all Preferred Activities for my Package using
getPackageManager().clearPackagePreferredActivities(getPackageName());
But is it posible only to clear a specific one? For example clear the Intent.CATEGORY_HOME but still keep the default for lets say android.media.action.IMAGE_CAPTURE?
I am talking newer devices HoneyComb and above.
I have tried to change the package name for the Image_Capture Activity but to no effect (makes sense since the User can reset the Preferred Activites per App not per Package, so the clearPackagePreferredActivities works just as that button).
If this is the only possibility to clear the defaults, than I would need to make two apks - one for the Home-App and one for the Photo-App to get the desired effect.
(Note that the photo-app does really nothing but is designed to bar the user from using camera as part of blocking of my Kiosk-App).

Switching between app icons programmatically in android

I have two different variants of an app with slightly different behavior. They share the same code, but the different behavior is through property files in the same project. I would like to have different icons for the apps.
Is there a way for me to change this programmatically? I have two sets of icons images in res/drawable-* folders, one for each app variant.
I've already looked at How to change an application icon programmatically in Android?, but that seems to be addressing a slightly different issue.
If I understand you, then you have an app, which functionality depends on a config file, and you want to have two different icon for the two installation of the app.
In this case, you have to change the package name, if you want to have these apps to be installed simultaneously. If so, you could change the icon manually too.
In any other case, you cannot change the icon of an application in running time.
If you are using ActionBarSherlock, try this:
getSupportActionBar().setIcon(R.drawable.ic_launcher_two);
If not, try this:
getActionBar().setIcon(R.drawable.ic_ic_launcher_two);

Implement custom launcher Folder class

I'm trying to figure out (if it's even possible) to override the behavior of the built in ICS launcher folders.
I have a specific and small change I'd like to add (simply add a button on the top to sort alphabetically to start with). From looking at the source for Launcher2 add the behavior should be easy enough, but I can't seem to figure out way to hook into the launcher and override specific bits.
I would hazard to guess that the correct approach is that you have to implement a full custom launcher (by altering the class I'm interested in changing and recompiling Launcher2) and that what I'm hoping to do isn't possible. Android/Java is not my day job so I'm hoping there might be a way that I'm not seeing that a more experienced developer is aware of.
In short is/how can I implement a custom subclass of com.android.Launcher2.Folder and have that used instead? Preferably with just a drop in app rather than having to completely override the normal ICS launcher app.
I'm trying to figure out (if it's even possible) to override the behavior of the built in ICS launcher folders.
No, sorry.
I would hazard to guess that the correct approach is that you have to implement a full custom launcher (by altering the class I'm interested in changing and recompiling Launcher2) and that what I'm hoping to do isn't possible.
Correct. Beyond that, you cannot simply reuse their code, as packages have to be unique in Android devices.
how can I implement a custom subclass of com.android.Launcher2.Folder and have that used instead?
Completely rebuild the firmware that contains the modified class, then use that modified firmware on your device. Or, refactor the entire home screen app into your own package, get it building as a standalone app (which may not be easy), and then add in your change.
Far simpler would be for you to make your own app widget that implements some sort of folder construct. That would not "override the behavior of the built in ICS launcher folders", but it could give you the functionality you seek.

Can you change your app name (this under icon in list of application) dynamically?

I am wondering which name will be better for my app. I am thinking about experiment, which will change name of application (in 10% downloaded apps). Later I could check statistics which app was used more often.
Is this possible?
No. The app name is specified in your manifest so it will be static. You could change the name in the titlebar of the app though.
Picking a good name is key.
depending on exactly what you want you have a few options. You can call
this.setTitle("New Title Here");
from an Activity and this will change the title that appears at the top of the screen just beneath the notification bar. If you are trying to change the title that appears in the launcher, or on the home screen under the icon I don't think you can do this programmatically. You'd have to create two seperate versions of your application and use the different values for < application android:label> inside your manifest for each of them. Or maybe you could create another values folder like values-hdpi if the values folder works the same as the layout and drawable folders (which I suspect it does, but I've never tested.) then it would pull the value from the Strings.xml file inside the hdpi folder if the device has high density display, so you could get a different name for those devices. Maybe using this method you could use a language modifier like values-esp and somehow force the app to go into 'spanish mode' for a certain subset of users so that it pulls this alternate value.
If I understand your question correctly, you want to know if it's possible to test different names on the Android Market, correct?
The only way to do this with the Google Market is to have two separate copies of your app, but using different package names for each. The name that appears in the Market is set on the Developer Console, and while it can be changed, you will not see two different entries for your app in the market.
This is because the market uses your package name to identify your app, not the app name that you supply.
So, while it's easy to change the display name of the app while it is running by using setTitle as #Tim and #Robby have said, this only changes the app title while it is running - it does not affect the name used in the Android package manager, and it also does not affect the name displayed in the Market.
As I say above, if you are wanting to test which name is more popular and therefore results in more downloads, you will need to have multiple apps on the market with different package names. You will also then have to consider how to handle upgrades, and if one name turns out to be very popular, I don't think there's any facility to "upgrade" the other users to your new package name since they are different packages and therefore there is no upgrade path. This means you'll either have to inconvenience users of the old name by somehow asking them to switch to the new app name, or maintain all named versions of your app for the expected lifetime of it.
If you do get your users to switch to the new app, you will then also have to consider how to migrate their data. This can be done (3G watchdog does it when you upgrade from the lite version to pro), but it's an extra layer of complexity that you can avoid.

Categories

Resources