问题描述:

I have two android applications- A and B.

I'm trying to package them as a single unit so that upon installation the system installs both apps. However, I could not find any reliable answer till now.

In A's manifest file I added activity tag of B, resulting in error.

Could anyone guide me on how to package two applications as a single unit?

Thanks in advance!

网友答案:

I do not believe this is possible. An APK corresponds to a single AndroidManifest.xml which corresponds to a single Application.

However, if you want mulitple "launchers" or icons, it is possible by exposing multiple Activities by adding IntentFilters to the ones you want (which take the launcher event). However, they are still, technically, a single application.

Update: Here's how to expose multiple Activities. The main activity would have something similar in the AndroidManifest.xml

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Copy-paste this inside the other Activities you want to expose. For example:

<activity 
        android:name="com.example.app.FirstActivity" 
        android:label="@string/first_app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity 
        android:name="com.example.app.SecondActivity" 
        android:label="@string/second_app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
相关阅读:
Top