我的AppMain
班级 [My class Name]Application
在我的应用程序中扩展了班级。那有一些全局变量。我在清单里面提到过。我的应用程序运行正常。我的应用程序中有退出按钮,可以使用System.exit(0);
.
之后,当我使用“最近的应用程序”选项启动我的应用程序时,它就崩溃了。(仅供参考。按住 Home 键,将出现最近的应用程序)
从应用列表启动应用就可以了。
我怎样才能解决这个问题?
这是我清单的一部分:
<application
android:name=".activity.MainApp"
android:debuggable="false"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
编辑:
崩溃日志:
04-16 19:04:59.416: E/AndroidRuntime(19649): FATAL EXCEPTION: main
04-16 19:04:59.416: E/AndroidRuntime(19649): java.lang.RuntimeException: Unable to resume activity {xxx.xxx.xxx..HomeActvity}: java.lang.NullPointerException
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.os.Looper.loop(Looper.java:123)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-16 19:04:59.416: E/AndroidRuntime(19649): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 19:04:59.416: E/AndroidRuntime(19649): at java.lang.reflect.Method.invoke(Method.java:521)
04-16 19:04:59.416: E/AndroidRuntime(19649): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-16 19:04:59.416: E/AndroidRuntime(19649): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-16 19:04:59.416: E/AndroidRuntime(19649): at dalvik.system.NativeStart.main(Native Method)
04-16 19:04:59.416: E/AndroidRuntime(19649): Caused by: java.lang.NullPointerException
04-16 19:04:59.416: E/AndroidRuntime(19649): at com.xxx.xxxx.xxx.DatabaseManager.selectFieldsFrom(DatabaseManager.java:161)
04-16 19:04:59.416: E/AndroidRuntime(19649): at com.xxx.xxxx.xxx.DBUtils.retrieveFromStore(DBUtils.java:75)
04-16 19:04:59.416: E/AndroidRuntime(19649): at com.xxx.xxxx.xxx.DBController.getAllWishList(DBController.java:407)
04-16 19:04:59.416: E/AndroidRuntime(19649): at xxx.xxxx.xxx.HomeActvity.retrieveFromListTable(HomeActvity.java:441)
04-16 19:04:59.416: E/AndroidRuntime(19649): at xxx.xxxx.xxx.HomeActvity.onResume(HomeActvity.java:642)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.Activity.performResume(Activity.java:3823)
04-16 19:04:59.416: E/AndroidRuntime(19649): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
04-16 19:04:59.416: E/AndroidRuntime(19649): ... 12 more
这是因为从最近的 apps.DB 启动时应用程序未从启动启动,System.exit(0);
因此显示空指针异常。
更新:
应用程序强制关闭,因为我将启动屏幕和主屏幕活动属性设置为Single Task
. 删除它后它工作正常。