Issue
I´ve encountered the problem that my app keeps crashing because of a NullPointerException. A databaseQuery cant be made because of a missing value.
I´ve investigated, that the following ist happening:
class A is intended by MainActivity (with IntentExtra int id
) .Class A
makes Intent on B
.
B
finishes by clicking the "back" button (the hardware back button works actually. The Problem is with that one in the upper left corner).
A.onCreate()
is called again (But the Intent creating this is not the same as before, thus not having the id Extra). But I´d like to return to the previous state of A
. There are instances of variables I need to have.
Is there any workaround? Or why is onCreate beeing called?
Solution
The Problem was:
Members of activitys get "wiped" when Stopped. To Prevent this you can use a SharedPreferences.
Here is a good discription.
--> Saving persitent state
Answered By - Maximus0000
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.