Issue
is it possible to tell these 2 states appart? close an app vs. turn the device into landscape/portrait. Because i won´t lose any data if the user closes the app but if he is bored and, lets say hes really bored, turns his device several times i won´t have this Safe/Load process all the time.
I´ve overwritten the on... methods to understand the android livecycle but i see no difference in behavior between turning the device and closing the activity.
im open for suggestions or a discussion.
I guess i need to explain my problem. I had the idea to safe data in the onPause method, but the problem is to differentiate between closing (where it should safe the data) and turning the device ( where it shouldn´t safe) don´t want to eat the battery.
Should i force the user to select landscape or portrait mode if he enters this special activity? or make it possible via a menu?.. i mean this would be a less smooth experiance for the user but easier for me somehow.
Solution
That should do the trick!
@Override
protected void onDestroy() {
super.onDestroy();
if(isChangingConfigurations()){
Toast.makeText(this,"got turned",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(this,"need to safe data",Toast.LENGTH_SHORT).show();
//safe data
}
}
Answered By - Nostramärus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.