0

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>
user2106413
  • 85
  • 1
  • 1
  • 9
  • 1
    make your activity's category as Launcher: – yahya Feb 27 '13 at 13:30
  • I am sorry if the comment may have offended anyone. My solution was already in the answer, and already upvoted. But as for the question it was really not researched and I may as well say not given enough though. SO is not for every trivial question. I mean look OP has code to both app then why not simply merge them. Is that really a problem or lack of effort. – Master Chief Feb 27 '13 at 14:21
  • Yes may be lack of effort and also lack of time. – user2106413 Feb 27 '13 at 14:52

2 Answers2

4

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).

EJK
  • 12,332
  • 3
  • 38
  • 55
  • when i am trying to launch the viewer than an alert is coming "Complete Action Using" 1) App & 2) Viewer. When i click viewer than it is working ok but when i click the app, the app crashes as it can't be used to read books. Can you help me in removing that. I have no idea why it is coming. – user2106413 Feb 27 '13 at 15:39
  • Hmmm. I am surprised to hear that alert. I have a similar app with 2 launchers and I get no such alert. The only difference I can see is that I have defined one of my activities with the following attribute: android:launchMode="singleTop". I doubt this will fix it however. – EJK Feb 27 '13 at 16:17
  • Could you please post the contents of your manifest? As for the crash, I suggest you examine the LogCat output or debug the application for more details. – EJK Feb 27 '13 at 16:18
  • Actually, upon closer inspection, I see one more important detail. One of my launchers has a "android:taskAffinity" attribute that names a separate task for that activity. I have edited my answer above to include this. Might be worth a try. – EJK Feb 27 '13 at 16:23
  • I have posted my manifest and the exception also. Please can you check and let me know if there is any error. – user2106413 Feb 28 '13 at 06:04
  • If you can check whether the android:taskAffinity is correct in my manifest or not – user2106413 Feb 28 '13 at 11:04
  • taskAffinity looks OK, but I suggest you read the docs at android.developer.com to be sure. My next suggestion is to start whittling-down your activities until they more closely resemble the ones I posted. Here are 2 suggestions to get you started: (1) Remove the intent filter with action VIEW. (2) Add icon attributes for each activity, and make sure that they are different. – EJK Feb 28 '13 at 14:49
0

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.

Community
  • 1
  • 1
Alpay
  • 1,350
  • 2
  • 24
  • 56