Install Application programmatically on Android
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Android does allow apps to initiate package installation, but the operating system places strong limits on silent installs for security reasons. The practical answer depends on your environment: a normal app can usually launch an install flow that requires user approval, while silent installation is reserved for device-owner, affiliated profile-owner, or privileged scenarios.
The Usual Case: Start an Installation Flow
For ordinary apps, the simplest approach is to hand an APK to the package installer and let the user confirm the installation.
On modern Android, that usually means sharing the APK through a FileProvider and launching the installer with an intent.
This does not silently install the app. It opens the system installer UI, and the user still controls whether the install proceeds.
More Control with PackageInstaller
If you need a store-like or enterprise-style flow, use PackageInstaller. It lets your app create an install session, stream the APK into it, and then commit the session.
In a real app, InstallStatusReceiver would be a BroadcastReceiver that reads the installer status from the callback intent extras.
The important restriction is that commit() may still require user intervention. The API gives you more control over package delivery, but it does not turn a regular app into a silent installer.
When Silent Install Is Actually Allowed
Android reserves silent install capability for tightly controlled environments. Examples include:
- device owner apps in enterprise management
- affiliated profile owner apps
- system or privileged apps on customized firmware
Outside those cases, the system intentionally keeps the final approval step with the user. That design prevents arbitrary apps from pushing other apps onto a device without consent.
Permissions and Unknown Sources
Apps that distribute packages outside a store may need the REQUEST_INSTALL_PACKAGES permission and may need the user to allow installs from that source. The exact user experience depends on Android version and device policy.
If your app tries to install from a raw file path without a FileProvider, newer Android versions will reject it. Secure content URIs are required for file sharing between apps.
Installation Is Not the Same as Visibility
Some workflows also need package visibility declarations to inspect whether another app is already installed. That is separate from the installation mechanism itself. Do not confuse "can I see packages" with "can I install a package".
Likewise, ADB-based installation commands are useful for development and device management, but they are not a general in-app installation strategy for production users.
Common Pitfalls
Expecting silent installation from a normal third-party app is the most common mistake. Android is designed to prevent that.
Using Uri.fromFile() on modern Android breaks because direct file URIs cannot be freely shared with the installer app.
Forgetting REQUEST_INSTALL_PACKAGES or the corresponding user approval flow can block the install path.
Assuming PackageInstaller always installs silently is incorrect. It often still ends in user confirmation unless the app has elevated management privileges.
Treating ADB or root-based solutions as ordinary production techniques leads to designs that only work on test devices.
Summary
- Normal Android apps can usually start an installation flow, not force a silent install.
- Use an installer intent for simple APK installs and
PackageInstallerfor more control. - Silent installs are generally limited to device-owner, profile-owner, or privileged contexts.
- Share APK files through a
FileProvider, not raw file URIs. - Plan the UX around user approval unless you are in a managed enterprise environment.
Related reading
- INSTALL_FAILED_NO_MATCHING_ABIS when install apk
- INSTALL_FAILED_UPDATE_INCOMPATIBLE when I try to install compiled .apk on device
- INSTALL_FAILED_USER_RESTRICTED android studio using redmi 4 device
- Install .ipa to iPad with or without iTunes
- Install shows error in console INSTALL FAILED CONFLICTING PROVIDER
- Installation failed with message Error android.os.ParcelableException java.io.IOException Requested internal only, but not enough space
- Installing ADB on macOS
- Instantiate and Present a viewController in Swift
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.