Android home-screen/launcher chooser does not show 'use by default for this action' option

StackOverflow https://stackoverflow.com//questions/10709779

  •  13-12-2019
  •  | 
  •  

Question

I am trying to launch the Home-screen/Launcher chooser dialog programmatically by using the following intent:

Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(Intent.createChooser(i, "Set My HomeScreen as default"));

But unfortunately the dialog that appears with the list of installed home-screen launchers does not have the Use by default for this action option at the bottom of the dialog. The following image shows how it looks:

HomeScreen

Interestingly after choosing my home-screen from the above chooser dialog, if I press home button from my that screen then Android automatically shows up a similar dialog which in fact has the Use by default for this option at the bottom of the dialog. Here is how it looks:

HomeScreen chooser

I am pretty clueless about what's wrong with the above code, it must be some silly mistake that I am not able to spot myself.

if anyone of can shed some light, then it would be of great help.

Thanks

Was it helpful?

Solution

createChooser() does not produce a "default for this action" checkbox. If you'd like the checkbox, instead pass an intent to startActivityForResult()

OTHER TIPS

This is how you do it on ICS:

final PackageManager packageManager = this.getPackageManager();
ComponentName componentName = new ComponentName(this, MainActivity.class);
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

Intent selector = new Intent(Intent.ACTION_MAIN);
selector.addCategory(Intent.CATEGORY_HOME);
startActivity(selector);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top