Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android APK within an APK?

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

I have two apps and the first one calls the other through an intent.. I don't have problem with this.. But what I need is to install only one apk file instead of two. And the first thing that came into my mind is to put a .apk file inside the other .apk file.. I really don't know if this is possible that's why I need your take on this. But if this is not possible, I hope someone can tell me what would be the best practice to doing this kind of thing.

I can make it as one application, but that would be my last solution.

like image 375
junmats Avatar asked Jan 26 '11 01:01

junmats


1 Answers

I just did that right now ...

I put apk 2 in raw/embeddedapk.apk

then this code ... started the installer for apk 2 ... **problem if user phone doesnt allow application not from market .. it will fail to install apk 2 ...

remember to delete temp file when the instalation is finished ....

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 I want to have apk 1 userinterface and apk 2 data provider as seperate apps in market. but i don't wnat users to down then individually when installing first time ...

  • apk 1 need data from apk 2, apk 2 does not have any activities ..

  • When user downloads apk 1 from market I want to auto instal apk 2 ...

  • I want to be able to update (market) apk1 & apk 2 independantly ...

like image 101
TeenInvader Avatar answered Sep 20 '22 17:09

TeenInvader