capacitor-apps-list
v0.4.0
Published
Capacitor plugin that provides list of installed apps on an Android device
Maintainers
Readme
capacitor-apps-list
Capacitor plugin that provides list of installed apps on an Android device. Works with Capacitor v8.
Each app constains the name, package name, category number and base64 encoded png icon.
Install
npm install capacitor-apps-list
npx cap syncNext click Android studio -> Sync project with gradle files.
Usage
Basic
Import the plugin in your service and call the method getAppsList().
import { AppsList, AppsListPlugin } from 'capacitor-apps-list';
@Injectable({
providedIn: 'root',
})
export class AppsWhitelistService {
getAppsList(): Promise<AndroidAppsDto> {
return this.appsListPlugin.getAppsList();
}
}You will receive a list of installed apps on the device.
export interface AndroidApp {
appName: string;
packageName: string;
category: AndroidAppCategory;
base64Icon: string;
}You can also get details of specific apps by their package names using the method getAppsDetails().
getAppsDetails(packageNames: string[]): Promise<AndroidAppsDto>Note that you will receive null at the index of a package name that is no longer installed
Displaying the icon
To display the icon in your application, you can use the following code:
<img [src]="'data:image/png;base64,' + app.base64Icon" alt="app icon" />Where app is an object of type AndroidApp.
Important
Breaking changes since 0.4
This plugin no longer uses QUERY_ALL_PACKAGES.
Since Play Store enforces very strict, case-by-case approval for QUERY_ALL_PACKAGES
(https://support.google.com/googleplay/android-developer/answer/10158779), and rejects most
apps that request it, this plugin instead uses the same technique third-party home-screen
launchers use to build their app drawer: it queries the system
for the activities that respond to ACTION_MAIN + CATEGORY_LAUNCHER, via a plain <queries>
declaration in AndroidManifest.xml - no special permission, and no Play Store review required.
<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent>
</queries>Legacy method migrated to: getAllPackages()
If your app has already been approved by Google Play for QUERY_ALL_PACKAGES (or you're only
targeting non-Play distribution), the plugin also exposes getAllPackages(), which keeps the
original behavior.
This library will NOT add the permission to your app's manifest for you. If you use
getAllPackages(), you must add it yourself to your app's AndroidManifest.xml:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />API
Capacitor plugin for listing installed apps on Android devices.
getAppsList()
getAppsList() => Promise<AndroidAppsDto>Get a list of installed apps on the device. Only apps that have a launcher icon (i.e. apps the user can open from the home screen / app drawer) are returned.
Returns: Promise<AndroidAppsDto>
getAllPackages()
getAllPackages() => Promise<AndroidAppsDto>Legacy method retained for consumers that still want (and have been approved by Google Play
for) the QUERY_ALL_PACKAGES permission. Enumerates every installed application, excluding
system apps that were not updated through the Play Store.
This library does NOT add the QUERY_ALL_PACKAGES permission to your app's manifest.
If you use this method, you must add it yourself to your app's AndroidManifest.xml:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />Returns: Promise<AndroidAppsDto>
getPackagesNamesDetails(...)
getPackagesNamesDetails(options: { packagesNames: string[]; }) => Promise<AndroidAppsDtoNullable>Get details of specific apps by their package names.
| Param | Type |
| ------------- | ----------------------------------------- |
| options | { packagesNames: string[]; } |
Returns: Promise<AndroidAppsDtoNullable>
isPackageInstalled(...)
isPackageInstalled(options: { packageName: string; }) => Promise<PackageIsInstalled>False if not installed OR invalid package name
| Param | Type |
| ------------- | ------------------------------------- |
| options | { packageName: string; } |
Returns: Promise<PackageIsInstalled>
Interfaces
AndroidAppsDto
| Prop | Type |
| ----------------- | ------------------------- |
| androidApps | AndroidApp[] |
AndroidApp
| Prop | Type |
| ----------------- | ----------------------------------------------------------------- |
| appName | string |
| packageName | string |
| category | AndroidAppCategory |
| base64Icon | string |
AndroidAppsDtoNullable
| Prop | Type |
| ----------------- | ------------------------------------------------------------- |
| androidApps | (AndroidApp | null)[] |
PackageIsInstalled
| Prop | Type |
| ----------------- | -------------------- |
| isInstalled | boolean |
Enums
AndroidAppCategory
| Members | Value |
| ------------------- | --------------- |
| Undefined | -1 |
| Game | |
| Audio | |
| Video | |
| Image | |
| Social | |
| News | |
| Maps | |
| Productivity | |
| Accessibility | |
