I need to get the name of launcher activity to launch the activity from my application. Any solution
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.
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.
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);
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); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With