简体   繁体   中英

NullPointer exception when resuming app on android

I am currently testing an app. This is the test case. Load the app and then go to google leader board. Then press home button and do some other tasks. Then come back to the app again by clicking on the app icon. When I do this I still see the previously loaded leaderboard. Afterwards if I click back button on the leaderboard to resume the app following exception occurs.

I have also listed the logcat output. I can't debug this to see whats null because dubug has been detached before this event. What can I do to solve this?

ava.lang.RuntimeException: Unable to start activity ComponentInfo{XXX: java.lang.NullPointerException
11-03 16:30:04.877: E/AndroidRuntime(619):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)


u=0} from pid 13361
11-09 22:51:02.015    3677-3677/? D/ChimeraCfgMgr﹕ Loading module com.google.android.gms.games from APK com.google.android.play.games
11-09 22:51:02.019    3677-3677/? D/ChimeraModuleLdr﹕ Module APK com.google.android.play.games already loaded
11-09 22:51:02.105   3677-13641/? V/BaseAuthAsyncOperation﹕ All scopes had been granted in the past, skip access token fetching
11-09 22:51:02.160   3677-13641/? V/BaseAuthAsyncOperation﹕ access token request successful
11-09 22:51:02.187      249-283/? I/ActivityManager﹕ Displayed  invalid entry.
11-09 22:51:09.750      249-943/? I/WindowState﹕ WIN DEATH: Window{41fda2b8 com.champ/com.champ.controllers.MainActivity paused=false}
11-09 22:51:09.750      249-494/? I/ActivityManager﹕ Process com.champ (pid 13361) has died.
11-09 22:51:13.836    3677-3677/? D/ChimeraCfgMgr﹕ Loading module com.google.android.gms.games from APK com.google.android.play.games
11-09 22:51:13.836    3677-3677/? D/ChimeraModuleLdr﹕ Module APK com.google.android.play.games already loaded
11-09 22:51:14.773      456-456/? D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 0ms
11-09 22:51:21.773      249-943/? D/dalvikvm﹕ GC_FOR_ALLOC freed 1448K, 17% free 19437K/23303K, paused 82ms, total 91ms
11-09 22:51:21.804  13789-13789/? D/dalvikvm﹕ Late-enabling CheckJNI
11-09 22:51:21.816      249-953/? I/ActivityManager﹕ Start proc com.champ for activity com.champ/.controllers.MainActivity: pid=13789 uid=10063 gids={1015, 1028, 3003}
11-09 22:51:25.586      249-835/? I/ActivityManager﹕ Process com.champ (pid 13789) has died.
11-09 22:51:25.590      249-835/? W/ActivityManager﹕ Force removing ActivityRecord{415b2150 com.champ/.controllers.ErrorActivity}: app died, no saved state
11-09 22:51:25.617  13857-13857/? D/dalvikvm﹕ Late-enabling CheckJNI
11-09 22:51:25.621      249-835/? I/ActivityManager﹕ Start proc com.champ for activity com.champ/.controllers.MainActivity: pid=13857 uid=10063 gids={1015, 1028, 3003}
11-09 22:51:25.687      249-953/? W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41db2610 attribute=null

Use try catch to get more info.

Did You save some Data in Application or Static Utils?

Because the page before You leader board is kill by System. When you back from Leader board,System rebuild it.

But some data become null.

In this case , you may use some data is null.

Simplely:
Add a check before you get data from Util.

public getA(){ if(a = null){a = b;} return a; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM