Android : Change App Label programmatically

后端 未结 8 1923
轻奢々
轻奢々 2020-11-28 11:27

How can I change application label to change app name shown from java code in android? I\'m refering to:



        
8条回答
  •  隐瞒了意图╮
    2020-11-28 11:52

    As Mister Smith said, it is not possible,

    but you could use multiple ActivityAlias, which can be enabled/disabled dynamically and point to the same targetActivity. Therefore create your chooser for the app name - let the user select one and enable the ActivityAlias via the packageManager:

    ComponentName componentName = new ComponentName(context, context.getPackageName() + "." + aliasName);
            context.getPackageManager().setComponentEnabledSetting(componentName,
                                                                   PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                                                                   PackageManager.DONT_KILL_APP);
    

    To hide the old alias, use the same code with the flag : COMPONENT_ENABLED_STATE_DISABLED

    You can also add the possibility to directly add a shortcut to the home launcher, after you enabled the alias. There are plenty ways described here on sow.

提交回复
热议问题