Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird behavior of activity orientation change in android

I am facing very strange problem in handling orientation of activity. Let me explain the scenario

I have Activity A and B.Currently A is in landscape mode and B(fixed) is in portrait mode. I am saving state of activity A if user change orientation of A. I went from A (landscape) to B(portrait) so in that case A is in background so it should call onSaveInstance(bundle) method. But it calls and when i come back then A's on Resume() called and i got exception onResume() can not called after onSaveInstance() for A.

This is something , make me annoying.

Update Edit

If both activity can have any orientation. Then activity A onSaveInstance(bundle) does not call while going to B and It works well

like image 936
Tofeeq Ahmad Avatar asked Dec 13 '12 10:12

Tofeeq Ahmad


1 Answers

Even though i still waiting for some logical description. But i solved my problem. When you are going from Activity A to B onsaveInstance() of a calls in every case. So when coming back activity restarted but onsaveInstance() does not call again. So i was getting

onResume() can not be called after onSaveInstance(Bundle)

Reason - I think as activity state is already save so it can not called onResume(). And main issue is onSaveInstance(Bundle) is not a part of activity life cycle so its very painful situation.

Solution - I remove super.onSavaInstance(Bundle) from onSaveInstance(Bundle). And problem solved. Its still working for orientation changes

like image 182
Tofeeq Ahmad Avatar answered Sep 18 '22 18:09

Tofeeq Ahmad