Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split Android app in two parts

I'm trying to understand if it is possible to split an Android App into two parts (installed from one APK). I looking into this to install one part on the Device memory and the other part on the SD-CARD. The two parts belong together and should not be installed separately.

Note: I need to separate not only resources, but also activities, so APK Expansion Files not a solution, because not provide such functionality.

like image 685
Louis Avatar asked Apr 03 '12 06:04

Louis


2 Answers

I think it will be possible. Can you try following approach?

  1. Create two apps
  2. In the Manifest file of first APK, you should have an Activity that is of MAIN and LAUNCHER category. This way your app will be visible in the Launcher list
  3. You should not have any Activity of MAIN and LAUNCHER category in 2nd APK, but you know which Activity you have to open as Launcher Activity of second app as it's your own app. This way your second app will never show up in Launcher list of apps
  4. Put 2nd APK in assets folder of first APK
  5. Whenever your main app wants to use contents from 2nd app, install 2nd app from assets folder (as mentioned here) with setting the install location on SDCard like this: android:installLocation="preferExternal" and then launch your desired activity of second app

I've not tried this yet but theoretically seems legit.

Let me know if this works. Thanks!

like image 137
Shrikant Ballal Avatar answered Sep 19 '22 14:09

Shrikant Ballal


APK Expansion Files

Google Play currently requires that your APK file be no more than 100MB. For most applications, this is plenty of space for all the application's code and assets. However, some apps need more space for high-fidelity graphics, media files, or other large assets. Previously, if your app exceeded 100MB, you had to host and download the additional resources yourself when the user opens the app. Hosting and serving the extra files can be costly, and the user experience is often less than ideal. To make this process easier for you and more pleasant for users, Google Play allows you to attach two large expansion files that supplement your APK.

Google Play hosts the expansion files for your application and serves them to the device at no cost to you. The expansion files are saved to the device's shared storage location (the SD card or USB-mountable partition; also known as the "external" storage) where your app can access them. On most devices, Google Play downloads the expansion file(s) at the same time it downloads the APK, so your application has everything it needs when the user opens it for the first time. In some cases, however, your application must download the files from Google Play when your application starts.

Downloading the Expansion Files

In most cases, Google Play downloads and saves your expansion files to the device at the same time it installs or updates the APK. This way, the expansion files are available when your application launches for the first time. However, in some cases your app must download the expansion files itself by requesting them from a URL provided to you in a response from Google Play's Application Licensing service.

The basic logic you need to download your expansion files is the following:

When your application starts, look for the expansion files on the shared storage location (in the Android/obb// directory). If the expansion files are there, you're all set and your application can continue. If the expansion files are not there: Perform a request using Google Play's Application Licensing to get your app's expansion file names, sizes, and URLs. Use the URLs provided by Google Play to download the expansion files and save the expansion files. You must save the files to the shared storage location (Android/obb//) and use the exact file name provided by Google Play's response.

Source

like image 45
W4R10CK Avatar answered Sep 19 '22 14:09

W4R10CK