I\'m looking for a way to launch the default android launcher programatically, something perhaps like the code below. Or do I have to add something to the manifest file? Tha
Following Garret Wilson's answer, here's an ugly one-liner, assuming context is your application context:
context.startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(context.getPackageManager().queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY).get(0).activityInfo.packageName));
This code assumes that the original system home activity is always the first result returned by queryIntentActivities, whereas the accepted answer returns the first home activity not belonging to the running package.
It's still unclear how to cleanly get the system home activity. Some threads mention that getPackageManager().resolveActivity(intent, flags) can be used for this, but it seems PackageManager.MATCH_SYSTEM_ONLY cannot be used with this method.