punyweakling
punyweakling

Reputation: 11

Allow a USER to remove app icon from Launcher?

I'm trying to programatically allow the USER to decide when to remove my app (a theme which is called from another app) from the launcher.

Currently using a button:

getPackageManager().setComponentEnabledSetting(new ComponentName("com.package.name","Main"),PackageManager.COMPONENT_ENABLED_STATE_DISABLED,0);

Sorry I'm not a coder and I'm doing something wrong, the button shows but no effect even with a launcher or phone restart.

Ideas?

Upvotes: 0

Views: 1469

Answers (2)

punyweakling
punyweakling

Reputation: 11

OK, I actually found some other similar code which worked.

I had kept intent.category.LAUNCHER and intent.action.MAIN in Main and moved the intent that calls my app from a parent app into a new class (duh).

Then I run the folowing on a button press by which the user can remove the icon from the launcher (requires launcher/phone restart):

PackageManager pm = getPackageManager(); ComponentName name = new ComponentName(this, Main.class);
pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);

Upvotes: 1

dst
dst

Reputation: 1788

Why is there even a launcher icon (necessary) in the first place? Does a theme need such an icon?

Apart from that: the same question was asked and answered here: you have to restart the launcher itself to update the icon-list.

Upvotes: 0

Related Questions