Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep one apk file in another apk file

Tags:

android

Can i keep one .apk file in another .apk file and when i install first apk file the second .apk file should be installed same as while uninstalling.

Thanks in adveance.

like image 318
Shashank Reddy Avatar asked Jan 10 '12 05:01

Shashank Reddy


Video Answer


2 Answers

Installing isn't too hard. You can put the second .apk file in the assets or raw resources folder of your first app. Then, when the first app runs, it can copy the .apk file to a temporary location and install the second app with something like this (lifted from this thread):

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 more complicated. You can't actually do what you want directly; you'll probably need a third app. It can register itself to receive ACTION_PACKAGE_REMOVED broadcasts and when it receives a broadcast that the first app is being removed, can remove the second app.

See this blog post for more details, including some settings that might be needed on the phone for non-market apps.

like image 167
Ted Hopp Avatar answered Oct 13 '22 00:10

Ted Hopp


It won't be an .apk rather you can create your another Application as Android Library. You can keep your Project as Library and can put in or use into Another Applications.

You can also check this thread.

like image 44
Lalit Poptani Avatar answered Oct 12 '22 23:10

Lalit Poptani