1
我有兩個Android應用程序的代碼說A和B.我想在B應用程序中實現A的代碼。爲此,我將A作爲庫(jar)添加到B項目中。 A本身包含活動和其他類。現在我想在點擊按鈕時調用A的根活動,並在B應用程序項目中運行A中的所有流。我也想在B工程的App內存中訪問A保存的數據。如何在我們的android應用程序中實現其他應用程序的代碼?
在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}
能否請您提出任何解決辦法嗎?在此先感謝
只是定義在mainfest文件中的所有活動,將工作,你可以給一些更多的信息是什麼錯誤你得到 – 2013-02-19 06:45:00
@KapilVats我在A項目的活動中得到空指針異常。它位於未找到應用程序實例。 A中還有一個清單,所以我需要再次定義它們嗎?我是否還需要提供權限 – 2013-02-19 06:47:48
是的,您需要重新定義權限 – 2013-02-19 06:50:18