Search code examples
javaandroidapkbarcode-scanner

Bundle APK with app


I am creating an app which uses ZLib (QR code reader), but it requires another app to be installed for it to work. I want to be able to package the other apps APK file within my APK. Is this possible?

Sidenote: I am trying doing this because my app will be used on an Amazon Fire kindle, but the prerequisite app is only on the Google Play store.


Solution

  • You can have a copy of the other app's APK in your app (e.g. within the assets directory).

    After your app is installed, you can copy the APK to the public storage and launch the package manager to install the other app from the APK:

    Intent pmIntent = new Intent(Intent.ACTION_VIEW)
            .setDataAndType(Uri.parse("file:///path/to/the.apk"), 
                            "application/vnd.android.package-archive");
    startActivity(pmIntent);
    

    But note that this requires the user to have enabled side loading of apps from third-party sources.