One .apk file that installs two apps

前端 未结 5 2117
渐次进展
渐次进展 2020-12-06 05:05

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 differen

相关标签:
5条回答
  • 2020-12-06 05:52

    You should either build 2 APKs are use APK Expansion Files.

    Btw, this is a security measure.

    0 讨论(0)
  • 2020-12-06 05:53

    It depends on your definition of "application". You cannot install 2 applications if you use the more official definition, as you can have only 1 <application> in your manifest.xml

    You can define several activities in your manifest.xml, and they can do seperate things, so in that way YOU CAN have 2 things a person might describe as "application" in one APK

    Just define multiple activities and use those could be defined as an option, but it depends on your definition of 'application', but in this case I'd say it would work

    0 讨论(0)
  • 2020-12-06 05:59

    Yes, you can install multiple apps by just installing one app.
    In Manifest.xml

    Project Structure:

    0 讨论(0)
  • 2020-12-06 06:04

    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, it will create two icons on the homescreen. The title 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'll 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.

    0 讨论(0)
  • 2020-12-06 06:07

    No.

    what you can do is to check if the second app is already installed, and if the answer is no, you can prompt the request to install the second app using this post.

    0 讨论(0)
提交回复
热议问题