Android APK in APK?

As stated in my question above, is it possible to have an apk file inside another apk? To further explain, here is my situation:

I have two applications, and the first calls the other with intent. I have no problem with this. But I need to install only one apk file instead of two. And the first thing that occurred to me was to put the .apk file inside another .apk file. I really don't know if it's possible why I need your solution. But if this is not possible, I hope someone will tell me what would be best practice in this.

I can do this as one application, but that would be my last decision.

+4
source share
4 answers

Perhaps the Android library is what you are looking for. This is the place where you can put some common code and include it in several applications (apks).

See this documentation in library projects .

+4
source

I just did it right now ...

I put apk 2 in raw / embeddedapk.apk

then this code ... launched the installer for apk 2 ... ** the problem is if the user’s phone does not allow the application not from the market .. he will not be able to install apk 2 ...

Remember to delete the temporary file when the installation is complete ....

try { InputStream in = this.getResources().openRawResource(R.raw.embeddedapk); byte[] b = new byte[in.available()]; int read = in.read(b); toast(read + " byte read"); String tempFileName = "embeddedapk.apk"; FileOutputStream fout = openFileOutput(tempFileName, MODE_WORLD_READABLE); fout.write(b); fout.close(); in.close(); File tempFile = getFileStreamPath(tempFileName); Intent i = getFileActionIntent(Intent.ACTION_VIEW, tempFile); startActivity(Intent.createChooser(i, "sdsds")); } catch (Exception ex){ Log.e("ero", "erer", ex); } 

My reason is because I want apk 1 userinterface and apk 2 data provider to be separate applications on the market. but I don’t want users to be reset individually when installing for the first time ...

  • apk 1 needs data from apk 2, apk 2 has no action.

  • When a user downloads apk 1 from the market, I want to use auto instal apk 2 ...

  • I want to be able to update (sell) apk1 and apk 2 independently ...

+5
source

Sorry, you're out of luck if you want the APK inside the APK.

Android does not allow this.

But I'm curious why you need this? You can call one action from another, even if they are in the same APK.

+3
source

You can program it as one application and have two launchers so that it appears to the user as two stand-alone applications.

You can also try to dismiss the intent and catch the case that no one is responding to it. Than you can open the market and recommend also installing the application.

The latter method is mainly performed by applications that need file browsers to select files. They send an intent, and if a file browser is not installed, they offer a toast informing them of the need to view the file to complete the task, and they open the market page of astro, the OI file manager, or other application that they prefer ...

+1
source

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


All Articles