How to change an application icon programmatically in Android?

前端 未结 10 2386
闹比i
闹比i 2020-11-21 22:33

Is it possible to change an application icon directly from the program?
I mean, change icon.png in the res\\drawable folder.
I would like t

10条回答
  •  一个人的身影
    2020-11-21 23:16

    Try this, it works fine for me:

    1 . Modify your MainActivity section in AndroidManifest.xml, delete from it, line with MAIN category in intent-filter section

    
        
            ==>  <== Delete this line
            
        
    
    

    2 . Create , for each of your icons. Like this

    
        
            
            
           
    
    

    3 . Set programmatically: set ENABLE attribute for the appropriate activity-alias

     getPackageManager().setComponentEnabledSetting(
            new ComponentName("ru.quickmessage.pa", "ru.quickmessage.pa.MainActivity-Red"), 
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    

    Note, At least one must be enabled at all times.

提交回复
热议问题