Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which launcher is running?

Usually there is one launcher on an Android device. But sometimes users install a few while only one of them is active.

How can I check which launcher is currently active on my Android device?

Thanks.

like image 212
Ran Avatar asked Jul 26 '11 15:07

Ran


People also ask

How do you tell which launcher I am using?

First, you need to navigate to Settings > Apps > All. Scroll down and look for your current application launcher. In the case of our example device, the default launcher is the Google Now Launcher.


2 Answers

The home screen is started with the Intent ACTION_MAIN with category CATEGORY_HOME (from the javadoc for Intent). Use a ResolveInfo to this intent to know what application will start.

This will give you the default Home application:

final Intent intent = new Intent(Intent.ACTION_MAIN); 
intent.addCategory(Intent.CATEGORY_HOME); 
final ResolveInfo res = getPackageManager().resolveActivity(intent, 0); 
if (res.activityInfo == null) {
    // should not happen. A home is always installed, isn't it?
} else if ("android".equals(res.activityInfo.packageName)) {
    // No default selected     
} else {
     // res.activityInfo.packageName and res.activityInfo.name gives you the default app
} 

Now, if you want to know which one is running, it will take more time, because ActivityManager is slow:

// instead of the best, query all activities that match:
final List<ResolveInfo> list = ((PackageManager)getPackageManager()).queryIntentActivities(intent, 0);
// TODO from there, use ActivityManager to know which one is running and is in the list
like image 91
rds Avatar answered Sep 17 '22 14:09

rds


private String findLauncherPackageName(){       
    final Intent intent = new Intent(Intent.ACTION_MAIN); 
    intent.addCategory(Intent.CATEGORY_HOME); 
    final ResolveInfo res = getPackageManager().resolveActivity(intent, 0); 
    Log.e("ANDRO_ASYNC", String.format("findLauncherPackageName()%s",res.activityInfo.packageName));
    return res.activityInfo.packageName;
}
like image 44
user462990 Avatar answered Sep 18 '22 14:09

user462990