Store one apk file in another apk file

Can I save one .apk file in another .apk file, and when I install the first apk file, the second .apk file should be installed the same as when uninstalling.

Thank you for attention.

+4
source share
2 answers

It will not be .apk , but you can create your own other application as Android Library . You can save your project as a library and contribute to it or use it in other applications.

You can also check this stream.

+2
source

Installation is not too complicated. You can put the second .apk file in the resource or source folder of your first application. Then, when the first application starts, it can copy the .apk file to a temporary location and install the second application with something like this (removed from this stream ):

 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile( new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive"); startActivity(intent); 

Uninstalling is a little trickier. You cannot do what you want; you will probably need a third application. He can register to receive ACTION_PACKAGE_REMOVED and when he receives a broadcast that the first application is removing, the second application can be deleted.

See this blog post for more details, including some of the options that your phone might require for non-market applications.

+3
source

Source: https://habr.com/ru/post/1390168/


All Articles