我有两个 android 应用程序的代码 A 和 B。我想在 B 应用程序中实现 A 的代码。为此,我将 A 作为库(jar)并将其添加到 B 项目中。A 本身包含活动和其他类。现在我想通过单击按钮调用 A 的根活动并在 B 应用程序项目中运行 A 中的所有流程。我还想在 B 项目的应用程序内存中访问 A 保存的数据。
在 B 项目中添加 jar 时,A 的 2 个活动工作正常。但随后它崩溃了。
我得到的错误在这里
02-19 12:35:59.260: W/dalvikvm(478): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-19 12:35:59.280: E/AndroidRuntime(478): FATAL EXCEPTION: main
02-19 12:35:59.280: E/AndroidRuntime(478): java.lang.NullPointerException: No application instance given
02-19 12:35:59.280: E/AndroidRuntime(478): at com.fsck.k9.mail.store.StorageManager.<init>(StorageManager.java:526)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.fsck.k9.mail.store.StorageManager.getInstance(StorageManager.java:497)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.fsck.k9.Account.<init>(Account.java:262)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.fsck.k9.Preferences.newAccount(Preferences.java:111)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.fsck.k9.activity.setup.AccountSetupBasics.onManualSetup(AccountSetupBasics.java:285)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.fsck.k9.activity.setup.AccountSetupBasics.onNext(AccountSetupBasics.java:256)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.fsck.k9.activity.setup.AccountSetupBasics.onClick(AccountSetupBasics.java:324)
02-19 12:35:59.280: E/AndroidRuntime(478): at android.view.View.performClick(View.java:2485)
02-19 12:35:59.280: E/AndroidRuntime(478): at android.view.View$PerformClick.run(View.java:9080)
02-19 12:35:59.280: E/AndroidRuntime(478): at android.os.Handler.handleCallback(Handler.java:587)
02-19 12:35:59.280: E/AndroidRuntime(478): at android.os.Handler.dispatchMessage(Handler.java:92)
02-19 12:35:59.280: E/AndroidRuntime(478): at android.os.Looper.loop(Looper.java:123)
02-19 12:35:59.280: E/AndroidRuntime(478): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-19 12:35:59.280: E/AndroidRuntime(478): at java.lang.reflect.Method.invokeNative(Native Method)
02-19 12:35:59.280: E/AndroidRuntime(478): at java.lang.reflect.Method.invoke(Method.java:507)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-19 12:35:59.280: E/AndroidRuntime(478): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-19 12:35:59.280: E/AndroidRuntime(478): at dalvik.system.NativeStart.main(Native Method)
02-19 12:35:59.290: W/ActivityManager(76): Force finishing activity com.test.k9test/com.fsck.k9.activity.setup.AccountSetupBasics
02-19 12:35:59.822: W/ActivityManager(76): Activity pause timeout for HistoryRecord{408e0b70 com.test.k9test/com.fsck.k9.activity.setup.AccountSetupBasics}
02-19 12:36:09.939: W/ActivityManager(76): Activity idle timeout for HistoryRecord{407edcd8 com.test.k9test/.MainActivity}
02-19 12:36:15.170: W/ActivityManager(76): Activity destroy timeout for HistoryRecord{408e0b70 com.test.k9test/com.fsck.k9.activity.setup.AccountSetupBasics}
你能建议任何解决方案吗?提前致谢