我想以编程方式更改我的应用程序图标,因此我在互联网上进行搜索,发现 private void enableComponent(ComponentName componentName) {
int state = packageManager.getComponentEnabledSetting(componentName);
if (state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
return;
}
packageManager.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
private void disableComponent(ComponentName componentName) {
int state = packageManager.getComponentEnabledSetting(componentName);
if (state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
return;
}
packageManager.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
}
<activity
android:name=".activity.HelloMActivity"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme.Base">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity-alias
android:name=".triangle"
android:enabled="false"
android:icon="@mipmap/ic_launcherep"
android:label="@string/app_name"
android:targetActivity=".activity.HelloMActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
可以使它工作。但是出了点问题,应用程序图标实际上在android启动器中已更改,但是在最新消息屏幕,我的应用程序图标和标签名称刚刚消失,这是什么原因?这是我的代码:
*ngIf