I made an application with this manifest
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.Activity"
android:label="@string/app_name" >
</activity>
<activity-alias
android:name="com.example.AliasIcon"
android:enabled="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:targetActivity="com.example.Activity"
android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
</application>
since the application does not require a launcher, I would like to display the application once and allow the user to select, save or hide the icon
In the code I wrote
showIcon = hideIcon.isChecked();
componentIcon = new ComponentName(getPackageName(), "com.example.AliasIcon");
if (showIcon){
flagIcon = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}else{
flagIcon = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
}
getPackageManager().setComponentEnabledSetting(componentIcon, flagIcon, PackageManager.DONT_KILL_APP);
hideIcon.setOnCheckedChangeListener(this);
showIcon is logical, hideIcon is CheckBox, componentIcon is ComponentName, flag Icon is int.
when I run the application (emulator on api8) everything works, but the icon does not disappear. If I click, a toast appears that says "the application is not installed." For it to disappear, I have to restart the emulator.
Is there a way to “update” the application launcher? Perhaps using android.intent.action.PACKAGE_CHANGED