我对我的应用有要求。我有一个用于显示书籍的应用程序和一个基本上为Viewer
的阅读书的应用程序。我有两个问题:
当我点击应用程序的第一个选项时,我得到了这个例外:
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)
更改清单后,它看起来像:
<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>
答案 0 :(得分:4)
您可以简单地将所有内容打包为一个应用程序(APK),并提供2个单独的启动器,一个用于Reader,一个用于Viewer。你的清单看起来像这样:
<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>
因此,在用户安装了您的应用后,他们会看到2个应用程序图标:一个将您带到阅读器,一个带您进入阅读器。这些是同一个应用程序的2个入口点(但对用户来说,它们是2个不同的应用程序)。
答案 1 :(得分:0)