Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One .apk file that installs two apps

This is a question concerning android applications with two different .apks (or two apps contained in the one .apk file)

I have two apps which do completely different things but are related, say one is a standard user app and one is an admin app. But a user can be both a user and an admin. I am wondering is it possible for me to create one .apk file that installs two applications to the phone? And how would I got about this?

Thanks, Matt

like image 660
MattTheHack Avatar asked May 21 '12 09:05

MattTheHack


People also ask

Can I install two apps at once?

Step 1: Tap & hold the recent button on your Android Device –>you will see all the recent list of applications listed in chronological order. Step 2: Select one of the apps you wish to view in split screen mode –>once the app opens, tap & hold the recent button once again –>The screen will split into two.

How can I install two versions of the same app in Android?

install “parallel space” you can install one version in that application and one that is already installed on your phone . make sure that you have setup of both the applications that you want to install. Why are there different versions of the same app on Android?


1 Answers

You can have two activity elements in the same manifest file, which have both the intent filter with action=MAIN and category=LAUNCHER. Further, you have also to use the attribute "android:taskAffinity" for both activity elements (see also here):

<application android:allowBackup="true"        
             android:icon="@drawable/main_icon"
             android:label="@string/main_name"
             android:theme="@style/AppTheme" >
             
    <activity android:name="com.foobar.MyActivity2"            
              android:taskAffinity="com.foobar.MyActivity2"
              android:icon="@drawable/icon1"
              android:label="@string/name1" >
        <intent-filter>
            <action   android:name="android.intent.action.MAIN"       />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>        
    
    <activity android:name="com.foobar.MyActivity2"
              android:taskAffinity="com.foobar.MyActivity2"
              android:icon="@drawable/icon1"
              android:label="@string/name2" >
        <intent-filter>
            <action   android:name="android.intent.action.MAIN"       />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>             
    
</application>

When the APK file with this manifest is installed on a device, then it will create two icons on the homescreen. The titles of these icons will be taken from the attributes android:label, and the icons will be taken from the attributes android:icon. In the list of apps under "Settings | Apps" you will see the name & icon defined by the attributes of the application tag. When you choose "uninstall" for this entry in the list of apps, then both "apps" will be removed from the device.

like image 56
user1364368 Avatar answered Sep 28 '22 01:09

user1364368