Passing Extras And Screen Rotation
This kind of questions appear periodically. Sorry if this has been covered before, but I'm a newbie and couldn't find the appropriate answer. It deals with the correct implementati
Solution 1:
Try this code to store the values for the activity
Long value;
protectedvoidonSaveInstanceState(Bundle onOrientChange) {
super.onSaveInstanceState(onOrientChange);
onOrientChange.putLong("myValue", value);
}
And restore the values in onCreate():
publicvoidonCreate(Bundle onOrientChange) {
if (onOrientChange!= null){
value = onOrientChange.getLong("myValue");
}
}
Usually you restore your state in onCreate(). It is possible to restore it in onRestoreInstanceState() as well, but not very common. (onRestoreInstanceState() is called after onStart(), whereas onCreate() is called before onStart().
Use the put methods to store values in onSaveInstanceState()
Post a Comment for "Passing Extras And Screen Rotation"