Devu Soman
Devu Soman

Reputation: 2266

How to get default home application?

I want to get default home application name.For this i used

Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.HOME");
        intent.addCategory("android.intent.category.DEFAULT");
        ResolveInfo resolveinfo =getApplicationContext().getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); 
defaultHomeName = resolveinfo.activityInfo.name;

This returns com.android.internal.app.ResolverActivity and when I tried following

    List<RunningTaskInfo> runningTasks =((ActivityManager) getApplicationContext().getSystemService("activity")).getRunningTasks(1);
    if (runningTasks != null && !runningTasks.isEmpty()) {
        for (int i = 0; i < runningTasks.size(); i++) {
            RunningTaskInfo runningtaskinfo = (RunningTaskInfo) runningTasks.get(i);

        }
    }

got home name as com.sec.android.app.twlauncher.Launcher inside this when on the home screen .

Why the same application shows different names?How to get a unique name for default home application for all devices?

Upvotes: 0

Views: 1379

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006674

Why the same application shows different names?

Because they are not the same application.

Specifically, com.android.internal.app.ResolverActivity is the resolver activity, what we tend to refer to as the activity chooser, or simply "chooser" for short. That comes up for resolveActivity() because there are two or more activities that can handle your chosen Intent.

How to get a unique name for default home application for all devices?

By using queryIntentActivities() on PackageManager, instead of resolveActivity(), you will get a list of all installed home screens. If this list has more than one entry on it, after filtering out your own home screen (should you be writing one), you have no reliable way necessarily of determining which of those is the "default home application".

Upvotes: 1

Related Questions