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

GitHub 代码仓playbott/android_package_installer

android_package_installer

Flutter Android 包安装程序插件

android_package_installer 项目封面
星标
7
复刻
26
最近推送(UTC)
2025年5月4日
项目状态
未归档

原始 README

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

android_package_installer

A Flutter plugin for installing Android package from apk file. Plugin uses Android Package Installer and requires minimum API Level version 21.

Using

import 'package:android_package_installer/android_package_installer.dart';

  int? statusCode = await AndroidPackageInstaller.installApk(apkFilePath: '/sdcard/Download/com.example.apk');
  if (statusCode != null) {
    PackageInstallerStatus installationStatus = PackageInstallerStatus.byCode(statusCode);
    print(installationStatus.name);
  }

To install the Android package the application will need permissions. You can use the permission_handler package to request them.

Setup

  1. Add the permissions to your AndroidManifest.xml file in <projectDir>/android/app/src/main/AndroidManifest.xml:
    • android.permission.REQUEST_INSTALL_PACKAGES - required for installing android packages.
    • android.permission.READ_EXTERNAL_STORAGE - required to access the external storage where the apk file is located.
<manifest xmlns:tools="http://schemas.android.com/tools" ...>

  <!-- ADD THESE PERMISSIONS: -->
  <!-- Android 10 Permissions -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  <!-- Android 11+ Permissions -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage"/>
  
  <application ...>
    <activity ...>

      ...

      <!-- ADD THIS INTENT FILTER -->
      <intent-filter>
        <action android:name="com.android_package_installer.content.SESSION_API_PACKAGE_INSTALLED"/>
      </intent-filter>
    </activity>

    <!-- ADD THIS PROVIDER -->
    <provider
      android:name="androidx.core.content.FileProvider"
      android:authorities="${applicationId}"
      android:grantUriPermissions="true">
      <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths"/>
    </provider>
  </application>
</manifest>
  1. Check external path in your custom paths file. If it doesn't exist, create it in <projectDir>/android/app/src/main/res/xml/file_paths.xml:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>
Rovsh G GitHub avatar
GitHub 作者

Rovsh G ↗

Dart/Flutter Developer

FreelanceYozgat, Turkey官方网站 ↗
语言DartKotlin

分类

此仓库发布的插件

使用的依赖

依赖清单 4 项

  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.1.8
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖^5.0.0

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

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

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

来源与维护

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

GitHub Docs — About repositories ↗