My Activity is getting null object exception when the app resumes after bing in the background

314 views Asked by At

I have an android app that has a second module included in the app when the main activity starts an activity in the module everything is good. The problem is if you go to another app and then resume this app the activity crashes with a null object pointer. My app uses Esri ArcGIS runtime SDK. I have a MapView open in the activity when the crash occurs. I don't have any problem with an open map in the MainActivity and the app goes to the background then back to the current app.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thevillages.myfirstapp, PID: 23267
    java.lang.RuntimeException: Unable to resume activity {com.thevillages.myfirstapp/com.thevillages.maplib.MapNavActivity}: com.esri.arcgisruntime.ArcGISRuntimeException: Null pointer.: object cannot be null.
   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4205)
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237)
   at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
   at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
   at android.os.Handler.dispatchMessage(Handler.java:107)
   at android.os.Looper.loop(Looper.java:214)
   at android.app.ActivityThread.main(ActivityThread.java:7356)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: com.esri.arcgisruntime.ArcGISRuntimeException: Null pointer.: object cannot be null.
   at com.esri.arcgisruntime.internal.jni.CoreGeoView.nativeResume(Native Method)
   at com.esri.arcgisruntime.internal.jni.CoreGeoView.b(SourceFile:5)
   at com.esri.arcgisruntime.a.i.f.g.d(SourceFile:3)
   at com.esri.arcgisruntime.mapping.view.GeoView$RenderingThread.resume(SourceFile:4)
   at com.esri.arcgisruntime.mapping.view.MapView.resume(SourceFile:1)
   at com.thevillages.maplib.MapNavActivity.onResume(MapNavActivity.java:816)
   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1446)
   at android.app.Activity.performResume(Activity.java:7939)
   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4195)
   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4237) 
   at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
   at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
   at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
   at android.os.Handler.dispatchMessage(Handler.java:107) 
   at android.os.Looper.loop(Looper.java:214) 
   at android.app.ActivityThread.main(ActivityThread.java:7356) 
   at java.lang.reflect.Method.invoke(Native Method) 
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
1

There are 1 answers

0
Jay Bowman On

I systematically went through my onCreate() method and added each piece of the code to find where the problem was. I found some code that was suspicious and I could not recall why I added the code. With the code removed the app works fine.