What is Package Manager?
PackageManager
provides methods for querying and manipulating installed packages and related permissions, etc. Some methods are only allowed to the system
userCode for Listing application names and their respective package names.private void getPackages() { List<ApplicationInfo> packages; PackageManager pm; pm = getPackageManager(); // get a list of installed apps. packages = pm.getInstalledApplications(0); for (ApplicationInfo packageInfo : packages) { String applicationName = (String) (packageInfo != null ? pm .getApplicationLabel(packageInfo) : "(unknown)"); Log.d("applicationName=" + applicationName, "package name=" + packageInfo.packageName); } }Code for Launching Application using just package name.Intent LaunchIntent = getPackageManager()
.getLaunchIntentForPackage("com.example.abc");
startActivity(LaunchIntent);
Thanks.
ReplyDelete