Its possible list apps by the package name it uses?
Example:
com.google.earth
com.google.android.apps.giant
And get a list with only two apps?
EDIT:
I want open google play store app in my device and search apps by multiples packages name.
Imagine this picture but with other apps... exactly the app with package name "com.google.earth" and "com.google.android.apps.giant"
From the official documentation, there is no way to achieve this.
You can only open a single app detail page:
market://details?id=<package_name>
the list of app from a developer:
market://search?q=pub:<publisher_name>
Or a search query
market://search?q=<seach_query>&c=apps
Yes, it is possible to do so. You can use the PackageManager as follows, which will grab all of the installed apps and put them in a List. Then, you can grab the two apps that you want from that List and store them in another list.
final PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
You can iterate over the List as follows:
for (ApplicationInfo packageInfo : packages) { ... }
In that loop, you can:
Get the installed package name:
packageInfo.packageName
Get the source directory:
packageInfo.sourceDir
Launch the Activity:
pm.getLaunchIntentForPackage(packageInfo.packageName)
Related
There are some Android applications that have expansion packs were the users can download expansions that suit them separately from the app like this one
(the main app) https://play.google.com/store/apps/details?id=com.dailyyoga.inc
(the expansion or whatever they are called) https://play.google.com/store/apps/details?id=com.dailyyoga.tranquility/
what are they called in android I tried the word package, expansion packs but with no luck until now, am I searching for the wrong word here, are they a separate android application.
They are called expansion packs? Simply the developer uses packageManager to access the extension app (usually when an in-app purshase made)
PackageManager pm = getPackageManager();
List<PackageInfo> packages = pm.getInstalledPackages();
for(PackageInfo package : packages) {
if(package.packageName.startWith("com.pack.extension.") {
// download package etc.
handleExtensionPackage(package);
}
}
I want to get a list of all apps installed on my device. My code is below:
PackageManager pm = getApplicationContext().getPackageManager();
List<PackageInfo> list = pm.getInstalledPackages(0);
When I try multiple user registered on my device (i.e. Android for Work), the API returns a list from the same user space/managed profile, which makes sense.
My question is, is there an option to get a list of all apps from the device (like Settings - Apps - All apps), no matter where the app is installed?
Use LauncherApps (only can get apps will shown in launcher), you can see how Launcher3 use it
https://developer.android.com/reference/android/content/pm/LauncherApps.html
I know in Android, I can invoke getInstalledPackages(0) of PackageManager API to get all the installed apps on device.
I am wondering is there a way or workaround to get the publisher's name of installed app by using Android SDK (i.e. no 3rd party library)??
The package that contains related classes, especially ApplicationInfo, there is no public interface for this (http://developer.android.com/reference/android/content/pm/package-summary.html). So i belive there's no way to do that.
I think there is no direct way to do that. Because that information is not available anywhere in the manifest or source code.
As a workaround, you can get the process name/package name, and find publishers name from google play store:
Pseudo code:
List<ApplicationInfo> appInfos = context.getPackageManager().getInstalledApplications(0);
for (ApplicationInfo appInfo : appInfos) {
String processName = appInfo.processName; // Example: com.google.android.youtube
String url = "https://play.google.com/store/apps/details?id=" + processName;
// Fetch publisher name from web here
...
}
I think, there is no android API to get the publisher's name of the application. You can get the publisher's and more information from the play store using this 3rd party API.
https://api.appmonsta.com/v1/stores/android/details/your-package-name.json?country=us
Replace the 'your-package-name' from API to the application package name.
First, you have to register with api.appmonsta.com to run this API.
In android I am listing the installed application list and storing in my private db. In that some application have same name, example there are 4 application named Maps, If one application gets update, other 3 applications records in private db get updated. How to differentiate those applications? I have used following code to get the installed application list.
PackageManager pm = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = pm.queryIntentActivities(intent,
PackageManager.PERMISSION_GRANTED);
ArrayList<String> applist = new ArrayList<String>();
ArrayList<String> packlist = new ArrayList<String>();
for (ResolveInfo rInfo : list) {
packlist.add(rInfo.activityInfo.packageName);
applist.add(rInfo.activityInfo.applicationInfo.loadLabel(pm)
.toString());
}
Use install paths as unique identifiers (they won't be installed in the same dir).
On the other hand, read this article if you have time. Packages have their configuration which contains UID. The link is from this answer.
You shouldn't differentiate two applications by their names. Some applications don't even have names associated with them (i.e. they are empty). The only sure way to distinguish two applications is by their package name (and this is heavily used by OS too).
Also note that while package name will always be the same, the UID of the application might change if application is fully uninstalled and then reinstalled again.
I'd like to add one little clarification that wasn't mentioned here.
Although there can't be two apps with the same package name, there can be several launcher activities within one app that user can see in launcher app. Yes, as you noticed, standard "Maps" application ("com.google.android.apps.maps" package) has several launcher activities like "Local", "Navigation", "Maps". It doesn't matter for user if these "apps" (or activities, in developer terms) are implemented in one application package or not.
Activity name ("com.google.android.maps.MapsActivity", you can retrieve this string by rInfo.activityInfo.name) is not unique itself too, because anyone can create an app with unique package name and an activity located in java package com.google.android.maps called MapsActivity.
Thus, if you want to find unique identifier for all these launcher activities, you should use combination of both app package name ("com.google.android.apps.maps") and activity name ("com.google.android.maps.MapsActivity").
I am creating a method to displays the installed applications in android. I gave the following lines of code to get the application list
PackageManager packageManager=this.getPackageManager();
List<PackageInfo> applist=packageManager.getInstalledPackages(0);
Iterator<PackageInfo> it=applist.iterator();
while(it.hasNext())
{
PackageInfo pk=(PackageInfo)it.next();
if(PackageManager.PERMISSION_GRANTED==packageManager.checkPermission(Manifest.permission.INTERNET, pk.packageName)) //checking if the package is having INTERNET permission
{
//some processing
}
}
}
Here everything is working fine but the list includes the system packages too. I need to get only the list of user installed packages. Is there any way to do??
What flag should we set in getInstalledPackages() to get the user installed packages?
The ApplicationInfo object will have FLAG_SYSTEM if it is installed on the firmware, so you can use that to filter those out.