I want to display Launcher app chooser dialog whenever I want but It is not displaying , app is getting closed.
This is my code :
getPackageManager().clearPackagePreferredActivities(getPackageName());
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(i);
If I set phone launcher as default by pressing always then it will not display the dialog , I am really confused why it is happening.