Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
513 views
in Technique[技术] by (71.8m points)

android - Bundle two apk into a single apk?

I have two completed projects, one for showing list of books and another is viewer app to read the books. But as the user have to download the book list app and after downloading he has to download the viewer app and i want to make it downloaded and installed at the starting. When i tried including the viewer app in the book list app then both got installed but when i made the apk then using the apk only the book list app is installed. Can anybody tell me what is the issue ? And is there any way to bundle two apk into one ? or what i should do ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can combine them into one project.

Create a project which has a package name of a base package name. For example, if your current apps are com.package.booklist and com.package.bookreader create a project with the package com.package. Now copy all the code from the book list into the com.package.booklist sub package, and all the code from the book reader into the com.package.bookreader.

Now you need to combine the AndroidManifests. You can copy all <activity> etc. elements into the new project's manifest. Now, you'll need to prefix all classes in the reader with .bookreader and all the classes in the book list with .booklist. So you'll have a manifest that looks something like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.package"
    android:versionCode="1"
    android:versionName="1" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name=".booklist.BookListActivity" >
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" >
                </category>

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

        <activity android:name=".bookreader.BookReaderActivity" >
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" >
                </category>

                <action android:name="android.intent.action.MAIN" >
                </action>
            </intent-filter>
        </activity>
    </application>

</manifest>

Remove the:

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

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

intent-filter from the Activity that you don't want in the launcher.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...