How to change an application icon programmatically in Android?

前端 未结 10 2140
闹比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 22:55

    Try this solution

    
            
                
                
            
        
    
        
            
                
                
            
        
    

    Add the following code when you want to change your app icon

    PackageManager pm = getPackageManager();
                        pm.setComponentEnabledSetting(
                                new ComponentName(YourActivity.this,
                                        "your_package_name.SplashActivity"),
                                PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                                PackageManager.DONT_KILL_APP);
    
                        pm.setComponentEnabledSetting(
                                new ComponentName(YourActivity.this,
                                        "your_package_name.SplashActivityAlias"),
                                PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                                PackageManager.DONT_KILL_APP);
    

提交回复
热议问题