Skip to content Skip to sidebar Skip to footer

Installing Multiple Android Apps With 1 Apk

I have two separate apps. Currently I am able to install them separately. I wanted to find out how I can install them using a single APK. I want to be able to have both apps stil

Solution 1:

you can define 2 luncher activity in your manifest file like bellow the result is what you want:

<applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:supportsRtl="true"android:theme="@style/AppTheme"><activityandroid:name=".MainActivity"android:icon="@mipmap/ic_launcher"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activityandroid:name=".MainActivity2"android:icon="@mipmap/ic_launcher"><intent-filter><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application>

Solution 2:

You cannot just install two apps directly without showing the user, the thing that you can do is to create a new app in which you will put your 2 apk files in the "raw" folder inside build folder. And push them to open together, those app will show a dialog to user to ask about permissions and will be installed if user allows.

Here is the code to do that:

for (int a=0;a<names.length;a++)
    {
        InputStream in = null;
        OutputStream out = null;
        try {
            in = getBaseContext().getResources().openRawResource(array[a]);  // Here "array" is actually and array holding the reference of apk files (eg. R.raw.firstApp)out = new FileOutputStream(Environment.getExternalStorageDirectory().getPath()+"/"+names[a]+".apk");  // Here "names" is an array holding the names of your apk files (eg. "firstApp")
            Log.e("Path" ,Environment.getExternalStorageDirectory().getPath());
            byte[] buffer = newbyte[1024];
            int read;
            while((read = in.read(buffer)) != -1){
                out.write(buffer, 0, read);
            }
            in.close();
            in = null;
            out.flush();
            out.close();
            out = null;
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+"/"+names[a]+".apk")), "application/vnd.android.package-archive");
            startActivity(intent);
        }catch(Exception e){
            // deal with copying problem
        }
    }

Solution 3:

Thank you for the advice. I was able to solve the issue by following, note I am leaving out the https part since I am unable to post links: Create a main activity project. Create another project for a service. Convert the service application to a library: developer.android.com/studio/projects/android-library.html#AddDependency

Fix any merge manifest issues: developer.android.com/studio/build/manifest-merge.html stackoverflow.com/questions/39178764/how-to-add-more-than-one-toolsreplace-in-android-manifest-application developer.android.com/studio/build/manifest-merge.html#inspect_the_merged_manifest_and_find_conflicts

Update the proguard-rules.pro files: -keepattributes EnclosingMethod

-Error in gradle build after updating Android Studio with log4j

Add a dependency to the main activity application in gradle: Compile project (':myserviceapp')

Post a Comment for "Installing Multiple Android Apps With 1 Apk"