user2106413
user2106413

Reputation: 85

How to install two apk at once?

I have a requirement for my app. I have an app for displaying books and an app for reading book basically a Viewer. I have two questions :

  1. Is it possible to install both apk at once at the starting ?
  2. Is it possible to integrate two apk ?

And when i click on the first option that is the app i am getting this exception:

FATAL EXCEPTION: main
Unable to instantiate activity ComponentInfo{jp.co.atori.A12022411/jp.co.atori.A12022411A.FSDMainLauncherActivity}: java.lang.ClassNotFoundException: jp.co.atori.A12022411A.FSDMainLauncherActivity in loader dalvik.system.PathClassLoader[/data/app/jp.co.atori.A12022411-1.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: jp.co.atori.A12022411A.FSDMainLauncherActivity in loader dalvik.system.PathClassLoader[/data/app/jp.co.atori.A12022411-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)

After changing manifest it looks like:

<activity
    android:name="jp.co.atori.A12022411.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="aircel-bookshelfviewer" />
    </intent-filter>
</activity>
<activity
    android:name="jp.co.atori.A12022411A.FSDMainLauncherActivity"
    android:label="@string/app_name"
    android:taskAffinity="com.jp.co.atori.A12022411A.FSDMainLauncherActivity.viewer"
    android:permission="com.smartebook.android.fsdreader.permission"
    android:theme="@android:style/Theme.NoTitleBar" >
    <intent-filter>
        <action android:name="FSDREADERAPPLICATION" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/*" />
    </intent-filter>
</activity>

Upvotes: 0

Views: 1913

Answers (2)

EJK
EJK

Reputation: 12534

You could simply package everything as one application (APK), and provide 2 separate launchers, one for the Reader, one for the Viewer. Your manifest would look something like this:

    <activity
        android:name=".ViewerActivity"
        android:icon="@drawable/viewer_logo"
        android:label="@string/viewer_activity_title" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".ReaderActivity"
        android:taskAffinity="com.yourapp.reader"
        android:icon="@drawable/reader_logo"
        android:label="@string/reader_activity_title" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

So after users have installed your app, they will see 2 application icons: one that takes you to your Reader, one that takes you to your Viewer. These are 2 entry points to the same app (but it appears to the user that they are 2 different apps).

Upvotes: 4

Alpay
Alpay

Reputation: 1368

When user installs one app, on its first startup you can simply check if the other one is installed on the device. See this post. If not installed, you can fire an intent for the play store and user installs the other app. You can check this.

Upvotes: 0

Related Questions