0

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.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
vandench
  • 1,973
  • 3
  • 19
  • 28

2 Answers2

5

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.

Community
  • 1
  • 1
Floern
  • 33,559
  • 24
  • 104
  • 119
  • What does the end user have to do to enable side loading? – vandench Mar 04 '17 at 15:50
  • It's a system setting "Apps from unknown sources", see also https://www.howtogeek.com/178357/how-to-sideload-apps-onto-your-kindle-fire/ – Floern Mar 04 '17 at 15:53
3

Your current approach is unsuitable in many ways.

You can use alternative libraries that can be embedded in your app and don't need any other application to be installed on the user's device. There are a handful of options on the Android Arsenal.

Farhad
  • 12,178
  • 5
  • 32
  • 60