I want to know the package name of an app and i only know the app name of that app. suppose i want to know the package name of an email app by just its name then how to get it
i just know the app name.
final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Log.d(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName));
}
this is the code to get the package name of all the app but i need to know for particular app.
Below is the code that will help to get Package Name of all installed apps
Hope this will helps
Summved
Should be something like this, since the app name is not unique you can have multiple package names that matches your requested app name.
Keep in mind that my function will return only the first package name that matches (you can change this logic very easily):
You use TextUtils.isEmpty method to check whether you got a result or not.