Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the launcher Activity name of an android application

I need to get the name of launcher activity to launch the activity from my application. Any solution

like image 274
user1767260 Avatar asked Oct 23 '12 09:10

user1767260


People also ask

How do I find the main activity of an Android app?

This can be found in the application's manifest. The main activity is the activity with the intent-filter whose name is android. intent. action.

What is Android launcher in my activity?

Launcher Activities are the activities that can be launched for a given intent. For example, when you press an app icon on the home screen, the StartActivity intent starts the activity you have specified as the launcher activity.


2 Answers

late but the better way it will give the exact intent to launch an activity

PackageManager pm = getPackageManager(); Intent intent=pm.getLaunchIntentForPackage(pacakgeName); startActivity(intent); 
like image 137
Vivek Bajpai Avatar answered Oct 14 '22 14:10

Vivek Bajpai


Use the following code to get the launcher activity of all packages:

        final PackageManager pm = getPackageManager();          Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);         mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);          List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);         Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));          for (ResolveInfo temp : appList) {              Log.v("my logs", "package and activity name = "                     + temp.activityInfo.packageName + "    "                     + temp.activityInfo.name);           } 
like image 23
Praful Bhatnagar Avatar answered Oct 14 '22 14:10

Praful Bhatnagar