Back Button Crashes App
Closed this issue · 0 comments
pedroliman commented
The app crashes when the ActionBar's back button is pressed in PlaceActivity.
Apparently this has something to do with the Activity's intent:
Android Logged Callstack:
FATAL EXCEPTION: main
Process: org.avaliabrasil.avaliabrasil, PID: 3107
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.avaliabrasil.avaliabrasil/org.avaliabrasil.avaliabrasil.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2279)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2329)
at android.app.ActivityThread.access$800(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:814)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at org.avaliabrasil.avaliabrasil.MainActivity.onCreate(MainActivity.java:78)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2243)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2329)
at android.app.ActivityThread.access$800(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
The callstack points to this line in MainActivity.java:
userId = getIntent().getExtras().getInt(USRID);
Toast.makeText(this,"Id de Usuário : " + userId,Toast.LENGTH_SHORT).show();`
Maybe passing the userId on the intent is not a good practice.