Repository navigation
Description
Summary / Feature Request
Add support for installing .apk files directly from FileExplorer by declaring the required package-install permission (REQUEST_INSTALL_PACKAGES) and handling the Android package installer intent flow.
Current Behavior
When tapping an .apk file inside FileExplorer to install it, the Android system package installer does not appear or silently rejects the install request. Currently, the app supports inspecting APKs via the APK Analyzer, but cannot trigger standard APK installation on Android 8.0+ (API 26+).
Expected Behavior
Tapping an .apk file (or selecting an Install action from the file menu / APK Analyzer) should:
- Check if the app has permission to request package installs (
PackageManager.canRequestPackageInstalls()on Android 8.0+ / API 26+). - If not granted, redirect the user to the system Install unknown apps settings screen (
Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES) for FileExplorer. - Once granted, launch the system package installer using a
content://URI provided viaFileProvider(Intent.ACTION_VIEW/Intent.ACTION_INSTALL_PACKAGEwithFLAG_GRANT_READ_URI_PERMISSION).
Root Cause & Testing Notes
- Environment tested: Xiaomi Redmi 7 (
onclite), tested with FileExplorer installed as a system app. - Observation: Prior to modifying the manifest, tapping an APK failed to invoke the system package installer popup.
- Verification: After adding the install permission declaration in
AndroidManifest.xml(and rebuilding/re-signing), tapping an.apkfile successfully triggered the Android package installer and installed apps as expected.
Suggested Fix
1. Declare Permission in AndroidManifest.xml
Add REQUEST_INSTALL_PACKAGES so Android allows FileExplorer to invoke the system package installer:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />2. Ensure FileProvider & Install Intent Handling
When opening/installing an .apk file on Android 7.0+ (API 24+) and Android 8.0+ (API 26+):
- Check
packageManager.canRequestPackageInstalls()onBuild.VERSION.SDK_INT >= Build.VERSION_CODES.O. Iffalse, prompt the user and openIntent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:$packageName")). - Serve the APK file through
FileProvider.getUriForFile(...)rather than afile://URI, and launch the installer intent withIntent.FLAG_GRANT_READ_URI_PERMISSIONandIntent.FLAG_ACTIVITY_NEW_TASKusing MIME typeapplication/vnd.android.package-archive.
Activity