- How to get list of Installed Apps in Android
- Project Description
- Environment Used
- Prerequisites
- Create Android Project
- strings.xml
- XML layout files
- main layout file (main.xml)
- ListView row item layout file (apklist_item)
- Second Activity’s layout file (apkinfo.xml)
- Create AppData class
- Custom BaseAdapter class
- Activity class
- MainActivity class (ApkListActivity.java)
- Second Activity class (ApkInfo.java)
- AndroidManifest.xml
- Output
- Project Folder Structure
- How to Get List of Installed Apps in Android
- 1. Creating application layout in xml
- 2. Writing Java class
- Download Complete Example
- Android Get List of Installed Apps Package Name With Icons Programmatically
- Note: Read below steps very carefully to add CardView and RecyclerView library inside your current project.
- How to Android Get List of Installed Apps Package Name With Icons Programmatically.
- Click here to download Android Get List of Installed Apps Package Name With Icons Programmatically project with source code.
- davidnunez / gist:1404789
- This comment has been minimized.
- full-of-foo commented Nov 15, 2013
- This comment has been minimized.
- full-of-foo commented Nov 15, 2013
- This comment has been minimized.
- banshee commented May 1, 2014
- This comment has been minimized.
- sunnychan2012 commented Jul 31, 2014
- This comment has been minimized.
- amr commented Sep 13, 2014
- Как получить список приложений, установленных пользователем на Android-устройстве?
- 9 ответов
How to get list of Installed Apps in Android
Android PackageManager class is used for retrieving various kinds of information related to the application packages that are currently installed on the device. You can get an instance of this class through getPackageManager().
Project Description
- In this Android 4 example, we will get list of installed apps in Android device and create custom ListView and populate its items using custom BaseAdapter.
- Here, we are going to implement OnItemClickListener event listener which calls onItemClick() callback method where we retrieve a particular row and create a object containing android application information and start another activity to display the installed app information such as Application name, package name, version, features, required permissions, path info, target SDK version, installed and modified date.
Environment Used
- JDK 6 (Java SE 6)
- Eclipse Indigo/Juno IDE for Java EE Developers
- Android SDK 4.0.3 / 4.2 Jelly Bean
- Android Development Tools (ADT) Plugin for Eclipse (ADT version 21.0.0)
- Refer this link to setup the Android development environment or this link to update to a latest version of Android SDK
Prerequisites
Create Android Project
- Create a new Android Project and enter the Application name as AppsList.
- Project name as AppsList.
- Enter the package name as com.ibc.android.demo.appslist.activity.
- Enter the Activity name as ApkListActivity.
- Enter the Layout name as main.
- Click Finish.
strings.xml
Open res/values/strings.xml and replace it with following content.
XML layout files
main layout file (main.xml)
This file defines a layout for displaying the result of installed apps in ListView widget. Open main.xml file in res/layout and copy the following content.
ListView row item layout file (apklist_item)
This layout defines only TextView widget. We can display of the icon of installed app in TextView using setCompoundDrawables() method.
Second Activity’s layout file (apkinfo.xml)
Create AppData class
This class extends android.app.Application which is used to maintain global application state, in this case contains an instance variable android.content.pm.PackageInfo. PackageInfo contains overall information about the contents of a package. This corresponds to all of the information collected from AndroidManifest.xml.
Create a new Java class “AppData.java” in package “com.ibc.android.demo.appslist.app” and copy the following code.
Custom BaseAdapter class
Create a new class “ApkAdapter” in “com.ibc.android.demo.appslist.adapter” package and copy the following code. This class extends android.widget.BaseAdapter to provide custom row layout and data for ListView.
Activity class
MainActivity class (ApkListActivity.java)
Open this activity class and copy the following code. In onCreate(), we get the list of installed apps and filtering out system app.
Second Activity class (ApkInfo.java)
Create a new class “ApkInfo.java” in package “com.ibc.android.demo.appslist.activity” and copy the following code.
AndroidManifest.xml
Output
Run your application
First Screen/Activity
Second Screen/Activity
Project Folder Structure
The complete folder structure of this example is shown below.
Источник
How to Get List of Installed Apps in Android
Android PackageManager class is used to retrieve information on the application packages that are currently installed on the device. You can get an instance of PackageManager class by calling getPackageManager() . PackageManager provides methods for querying and manipulating installed packages and related permissions, etc. In this Android example, we we get list of installed apps in Android.
packageManager.getInstalledApplications() return a List of all application packages that are installed on the device. If we set the flag GET_UNINSTALLED_PACKAGES has been set, a list of all applications including those deleted with DONT_DELETE_DATA (partially installed apps with data directory) will be returned.
1. Creating application layout in xml
activity_main.xml
As you can see in the attached screenshot, we will be creating a ListView to show all of the installed applications in android.
snippet_list_row.xml
This layout is being used by the ListView Adapter for representing application details. It shows application icon, application name and application package.
2. Writing Java class
AllAppsActivity.java
This is the main application class that is used to initialize and list the installed applications. As getting the list of application details from PackageManage is a long running task, we will do that in AsyncTask. Also, this class is using custom Adapter “ApplicationAdapter” for custom ListView.
ApplicationAdapter.java
Download Complete Example
Download complete Eclipse project source code from GitHub.
Источник
Android Get List of Installed Apps Package Name With Icons Programmatically
In this tutorial we would going to create an android application which would display us all the only externally installed applications on our android mobile phone device. The application display into custom ListView (RecyclerView) and show us App icon, app name and app package name on screen. This application is designed into RecyclerView along with CardView. So here is the complete step by step tutorial for Android Get List of Installed Apps Package Name With Icons Programmatically.
Note: Read below steps very carefully to add CardView and RecyclerView library inside your current project.
1. Open your project’s build.gradle ( Module : app ) file.
2. Please add below code inside your build.gradle ( Module : app ) file.
3. Screenshot of build.gradle ( Module : app ) file after adding above code.
Here your go now both libraries is successfully imported into our project now next step is to start coding.
How to Android Get List of Installed Apps Package Name With Icons Programmatically.
Code for MainActivity.java file.
Code for ApkInfoExtractor.java file.
Code for AppsAdapter.java file.
Code for activity_main.xml layout file.
Code for cardview_layout.xml layout file.
Screenshot:-
Click here to download Android Get List of Installed Apps Package Name With Icons Programmatically project with source code.
Источник
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
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:
Источник
Как получить список приложений, установленных пользователем на Android-устройстве?
В настоящий момент я использую следующий фрагмент кода:
Но он возвращает приложения, которые были установлены как производителем устройства, так и мной. Как его ограничить, чтобы возвращались только те приложения, которые я установил?
9 ответов
Зелимир ответил правильно. Но в некоторых случаях он не предоставит вам все установленные сторонние приложения. ApplicationInfo также имеет флаг FLAG_UPDATED_SYSTEM_APP , который установлен
Если это приложение было установлено как обновление встроенного системного приложения
На моем смартфоне такие приложения включают Amazone Kindle, Adobe Reader, Slacker Radio и другие. Эти приложения не поставлялись с телефоном и были установлены из Google Play Store. Таким образом, их можно рассматривать как сторонние приложения.
Так что вы также можете проверить флаг FLAG_UPDATED_SYSTEM_APP .
Если я сделаю pkgAppsList.get (0), он вернет объект ResolveInfo. Как мне получить такую информацию, как значок и имя пакета?
Просто сделай это:
Класс Android PackageManager используется для получения информации о пакетах приложений, которые в настоящее время установлены на устройстве. Вы можете получить экземпляр класса PackageManager, вызвав getPackageManager (). PackageManager предоставляет методы для запроса и управления установленными пакетами и соответствующими разрешениями и т. Д. В этом примере Android мы получаем список установленных приложений в Android.
PackageManager packageManager = getPackageManager (); Список list = packageManager.getInstalledApplications (PackageManager.GET_META_DATA)
PackageManager.getInstalledApplications () возвращает список всех пакетов приложений, установленных на устройстве. Если мы установим флаг GET_UNINSTALLED_PACKAGES, будет возвращен список всех приложений, включая те, которые были удалены с помощью DONT_DELETE_DATA (частично установленные приложения с каталогом данных).
Ответ Николая правильный, но его можно оптимизировать с помощью итератора. Вот что я придумал:
Отвечая на этот вопрос для Android 11 / API 30
context.getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA); Приведенный выше код возвращает список системных приложений, поскольку пользовательские приложения не отображаются по умолчанию, вам необходимо добавить разрешение ниже в манифест, чтобы получить список пользовательских приложений.
Если вы хотите узнать, как это сделать в Kotlin, это показано ниже, хотя, как упоминалось ранее Ketan sangle, вам нужно будет добавить в свой файл AndroidManifest.xml.
В этом случае я использовал системный флаг, чтобы исключить системные приложения, и вы можете найти другие флаги здесь
Источник