搜索插件、代码仓与 APP 分类

GitHub 代码仓g123k/flutter_plugin_device_apps

flutter_plugin_device_apps

Flutter 插件,用于获取已安装应用程序的列表(iOS 尚未支持)。

flutter_plugin_device_apps 项目封面
星标
104
复刻
141
最近推送(UTC)
2024年7月11日
项目状态
已归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

Device Apps plugin for Flutter (UNMAINTAINED)

Pub

A plugin to list installed applications on an Android device (⚠️ iOS is not supported). You can also listen to app changes (eg: installations, updates…)

BREAKING CHANGE - 05th May 2021

May 5 2021 will mark a breaking change on how applications requesting QUERY_ALL_PACKAGES are accepted in the Google Play (and only this app store !). Quoting from the doc:

Permitted use involves apps that must discover any and all installed apps on the device, for awareness or interoperability purposes may have eligibility for the permission. Permitted use includes; device search, antivirus apps, file managers, and browsers.

Apps granted access to this permission must comply with the User Data policies, including the Prominent Disclosure and Consent requirements, and may not extend its use to undisclosed or invalid purposes.

More info here: https://support.google.com/googleplay/android-developer/answer/10158779

Starting with version 2.1.0 of this plugin, the QUERY_ALL_PACKAGES permission won't be requested by default!

Change with Android 11

Starting with Android 11, Android applications targeting API level 30, willing to list "external" applications have to declare a new "normal" permission in their AndroidManifest.xml file called QUERY_ALL_PACKAGES. A few notes about this:

  • A normal permission doesn't require the user consent
  • Before version 2.1 of this plugin, the permission was requested automatically. This is not the case anymore

If you want to use, simply add the following to your AndroidManifest.xml:

<manifest...>

    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />

</manifest>

However, publishing applications on the Google Play with this kind of feature may change in the future. Quoting from the documentation:

In an upcoming policy update, look for Google Play to provide guidelines for apps that need the QUERY_ALL_PACKAGES permission.

👍 Right now, there is no limitation, but be aware that this may change in the future.

Getting Started

First, you have to import the package in your dart file with:

import 'package:device_apps/device_apps.dart';

List of installed applications

To list applications installed on the device:

List<Application> apps = await DeviceApps.getInstalledApplications();

You can filter system apps if necessary.

Note: The list of apps is not ordered! You have to do it yourself.

Get apps with a launch Intent

A launch Intent means you can launch the application.

To list only the apps with launch intents, simply use the onlyAppsWithLaunchIntent: true attribute.

// Returns a list of only those apps that have launch intent
List<Application> apps = await DeviceApps.getInstalledApplications(onlyAppsWithLaunchIntent: true, includeSystemApps: true)

Get an application

To get a specific application info, please provide its package name:

Application app = await DeviceApps.getApp('com.frandroid.app');

Check if an application is installed

To check if an app is installed (via its package name):

bool isInstalled = await DeviceApps.isAppInstalled('com.frandroid.app');

Open an application

To open an application (with a launch Intent)

DeviceApps.openApp('com.frandroid.app');

Open an application settings screen

To open an application settings screen

DeviceApps.openAppSettings('com.frandroid.app');

Uninstall an application

To open the screen to uninstall an application:

  1. Add this permission to the AndroidManifest.xml file:
<manifest...>

    <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />

</manifest>
  1. Call this method:
DeviceApps.uninstallApp('com.frandroid.app');

Include application icon

When calling getInstalledApplications() or getApp() methods, you can also ask for the icon. To display the image, just call:

Image.memory(app.icon);

Listen to app changes

To listen to applications events on the device (installation, uninstallation, update, enabled or disabled):

Stream<ApplicationEvent> apps = await DeviceApps.listenToAppsChanges();

If you only need events for a single app, just use the Stream API, like so:

DeviceApps.listenToAppsChanges().where((ApplicationEvent event) => event.packageName == 'com.frandroid.app')
Edouard Marquez GitHub avatar
GitHub 作者

Edouard Marquez ↗

Android & Flutter developer

Paris, France官方网站 ↗
语言DartJavaRubyObjective-C

分类

使用的依赖

依赖清单 1 项

  • flutter{"sdk":"flutter"}

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗