apk_manager 0.0.1 copy "apk_manager: ^0.0.1" to clipboard
apk_manager: ^0.0.1 copied to clipboard

PlatformAndroid

A Flutter plugin that allows you to manage and install apps on Android devices.

Install and manage apps on Android devices.

This plugin is still in development, use with caution as the API might change in upcoming versions.

Features #

Use this plugin in your Flutter Android App to:

  • Install APKs
  • Uninstall installed apps
  • Get app info from installed apps or APKs
  • Launch installed apps

Getting started #

This plugin uses the Android system APIs, most API calls need their respective permission to be granted.

Declare them in your AndroidManifest.xml like this:

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

Usage #

The plugin does not need to be initialized and can be used directly by calling the static methods of the ApkManager class.

Some calls need their respective permissions to be granted, use a plugin like permission_handler to check and request permissions.

final permission = Permission.requestInstallPackages;
if ((await permission.status).isDenied) {
  await permission.request();
}

Once the permissions are granted you start using the respective static methods.

Installing an APK #

To install an APK, use the installApk method. A system dialog will be shown to confirm the installation.

final result = await ApkManager.installApk(path: '/path/to/file.apk');

Uninstalling an app #

You can uninstall an app using the uninstallApp method by providing the app’s package name. A system dialog will be shown to confirm the uninstallation.

await ApkManager.uninstallApp('com.example.app');

Due to limitations of the uninstall api it's currently not possible to detect when the user cancels the uninstall in the system dialog.

Getting the package name from an APK #

To extract the package name from an APK file:

final packageName = await ApkManager.getPackageNameFromApk('/path/to/file.apk');

Getting app information #

You can retrieve information about an installed app using its package name:

final info = await ApkManager.getAppInfo('com.example.app');
if (info != null) {
  print('App version: ${info.versionName}');
}

Checking if an app is installed #

To check if a specific package is currently installed:

final isInstalled = await ApkManager.isAppInstalled('com.example.app');

Checking if an APK is installed #

To check if an APK file corresponds to an installed app:

final isInstalled = await ApkManager.isApkInstalled('/path/to/file.apk');

Launching an app #

You can launch an installed app using its package name:

final success = await ApkManager.launchApp('com.example.app');
2
likes
150
points
48
downloads

Publisher

verified publisherwearetoni.com

Weekly Downloads

A Flutter plugin that allows you to manage and install apps on Android devices.

Homepage
Repository (GitHub)
View/report issues

Topics

#flutter #android #apk

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on apk_manager

Packages that implement apk_manager