Check installed packages android

How can I find if a particular package exists on my Android device?

How can I find whether a particular package or application, say: com.android.abc , exists on my Android device?

9 Answers 9

Call any of the below method with the package name.

Without using a try-catch block or iterating through a bunch of packages:

Kotlin

We can check like this:

Make method for package check ! this credit goes to «Kavi» https://stackoverflow.com/a/30708227/6209105

You should use PackageManager ‘s function called getInstalledPackages() to get the list of all installed packages and the search for the one you are interested in. Note that package name is located in PackageInfo.packageName field.

If you just want to use adb:

it will list all installed packages.

You can use pm.getPackageUid() instead of iterating over the pm.getInstalledApplications()

Since some devices have reported that the «getInstalledPackages» can cause TransactionTooLargeException (check here, here and here), I think you should also have a fallback like I did below.

This issue was supposed to be fixed on Android 5.1 (read here), but some still reported about it.

Источник

davidnunez / gist:1404789

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

pm list packages -f

This comment has been minimized.

Copy link Quote reply

full-of-foo commented Nov 15, 2013

This comment has been minimized.

Copy link Quote reply

full-of-foo commented Nov 15, 2013

Nice one liner: » adb shell ‘pm list packages -f’ »

This comment has been minimized.

Copy link Quote reply

banshee commented May 1, 2014

And for just the packages:

adb shell ‘pm list packages -f’ | sed -e ‘s/.*=//’ | sort

Need to delete a bunch of things? This gives you an uninstall for everything that’s installed; cut and paste to adjust:

adb shell ‘pm list packages -f’ | sed -e ‘s/.*=//’ | sed -e ‘s/^/adb uninstall /’ | sort | less

Читайте также:  Com android browser apk

This comment has been minimized.

Copy link Quote reply

sunnychan2012 commented Jul 31, 2014

how to save it as a notepad text file?
I found the answer:
adb shell pm list packages -f > b:\1.txt

This comment has been minimized.

Copy link Quote reply

amr commented Sep 13, 2014

Building up on banshee’s one liner, for me there was a trailing \r, removing it was needed, as such:

adb shell ‘pm list packages -f’ | sed -e ‘s/.*=//’ | sed ‘s/\r//g’ | sort

Only then I was able to do get the following to work:

Источник

How to get a list of installed android applications and pick one to run

I asked a similar question to this earlier this week but I’m still not understanding how to get a list of all installed applications and then pick one to run.

and this only shows application that are preinstalled or can run the ACTION_MAIN Intent type.

I also know I can use PackageManager to get all the installed applications, but how do I use this to run a specific application?

20 Answers 20

Here’s a cleaner way using the PackageManager

Following is the code to get the list of activities/applications installed on Android :

You will get all the necessary data in the ResolveInfo to start a application. You can check ResolveInfo javadoc here.

Another way to filter on system apps (works with the example of king9981):

Here a good example:

Getting list of installed non-system apps

To filter on sytem based apps :

To get al installed apps you can use Package Manager..

To run you can use package name

You can Find the List of installed apps in Android Device by using below code, «packageInfo» Contains Installed Application Information in Device. we can retrive Intent for the application installed from the packageinfo object and by using startactivity(intent), can start application. it is up to you how you organize the UI either Listview or Gridview. so on click event based on position, you can retrive intent object and start activity intent.

I had a requirement to filter out the system apps which user do not really use(eg. «com.qualcomm.service», «update services», etc). Ultimately I added another condition to filter down the app list. I just checked whether the app has ‘launcher intent’.

So, the resultant code looks like.

If there are multiple launchers in a one package above code has a problem. Eg: on LG Optimus Facebook for LG, MySpace for LG, Twitter for LG contains in a one package name SNS and if you use above SNS will repeat. After hours of research I came with below code. Seems to work well.

@Jas: I don’t have that code anymore, but I’ve found something close. I’ve made this to search for «components» of my application, they are just activities with a given category.

Читайте также:  Открытый мир машины андроид

I’ve commented the part where it gets the activity name, but it’s pretty straightforward.

Clean solution that filter successfuly out system apps

The idea behind this solution is that the main activity of every system app does not have a custom activity icon. This method gives me an excellent result:

context.getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA); Should return the list of all the installed apps but in android 11 it’ll only return the list of system apps. To get the list of all the applications(system+user) we need to provide an additional permission to the application i.e

Since Android 11 (API level 30), most user-installed apps are not visible by default. You must either statically declare which apps and/or intent filters you are going to get info about in your manifest like this:

Or require the QUERY_ALL_PACKAGES permission.

After doing the above, the other answers here still apply.

Источник

How to check programmatically if an application is installed or not in Android?

We have installed applications programmatically.

  1. If the application is already installed in the device the application is open automatically.
  2. Otherwise install the particular application.

Guide Me. I have no idea. Thanks.

15 Answers 15

Somewhat cleaner solution than the accepted answer (based on this question):

I chose to put it in a helper class as a static utility. Usage example:

This answer shows how to get the app from the Play Store if the app is missing, though care needs to be taken on devices that don’t have the Play Store.

The above code didn’t work for me. The following approach worked.

Create an Intent object with appropriate info and then check if the Intent is callable or not using the following function:

If you know the package name, then this works without using a try-catch block or iterating through a bunch of packages:

This code checks to make sure the app is installed, but also checks to make sure it’s enabled.

Check App is installed or not in Android by using kotlin.

Creating kotlin extension.

Now, can check if app is install or not

A simpler implementation using Kotlin

And call it like this (seeking for Spotify app):

Cleaner solution (without try-catch) than the accepted answer (based on AndroidRate Library):

I think using try/catch pattern is not very well for performance. I advice to use this:

Try this

This code is used to check weather your application with package name is installed or not if not then it will open playstore link of your app otherwise your installed app

All the answers only check certain app is installed or not. But, as we all know an app can be installed but disabled by the user, unusable.

Читайте также:  Launcher для тв бокса андроид

Therefore, this solution checks for both. i.e, installed AND enabled apps.

Call the method isPackageInstalled() :

Now, use the boolean variable isAppInstalled and do whatever you want.

Источник

Package visibility in Android 11

On Android 10 and earlier, apps could query the full list of installed apps on the system using methods like queryIntentActivities() . In most cases, this is far broader access than is necessary for an app to implement its functionality. With our ongoing focus on privacy, we’re introducing changes on how apps can query and interact with other installed apps on the same device on Android 11. In particular, we’re bringing better scoped access to the list of apps installed on a given device.

To provide better accountability for access to installed apps on a device, apps targeting Android 11 (API level 30) will see a filtered list of installed apps by default. In order to access a broader list of installed apps, an app can specify information about apps they need to query and interact with directly. This can be done by adding a element in the Android manifest.

For most common scenarios, including any implicit intents started with startActivity() , you won’t have to change anything! For other scenarios, like opening a specific third party application directly from your UI, developers will have to explicitly list the application package names or intent filter signatures like this:

If you use Custom Tabs to open URLs, you might be calling resolveActivity() and queryIntentActivities() in order to launch a non-browser app if one is available for the URL. In Android 11 there’s a better way to do this, which avoids the need to query other apps: the FLAG_ACTIVITY_REQUIRE_NON_BROWSER intent flag. When you call startActivity() with this flag, an ActivityNotFoundException will be thrown if a browser would have been launched. When this happens, you can open the URL in a Custom Tab instead.

In rare cases, your app might need to query or interact with all installed apps on a device, independent of the components they contain. To allow your app to see all other installed apps, Android 11 introduces the QUERY_ALL_PACKAGES permission. In an upcoming Google Play policy update, look for guidelines for apps that need the QUERY_ALL_PACKAGES permission.

When targeting API level 30 and adding a element to your app, use the latest available release of the Android Gradle plugin. Soon we’ll be releasing updates to older Android Gradle plugin versions to add support for this element. You can find more information and use cases about Package Visibility in the developer documentation.

Источник

Оцените статью