Skip to content Skip to sidebar Skip to footer

On Rotation I Get "Unable To Destroy Activity ... Can Not Perform This Action After OnSaveInstanceState"

Hi and thank you for any help. I am only at the very beginning of configuring my code to handle rotation: I have implemented onDestroy(), but not yet any onSaveInstanceState() or o

Solution 1:

Thanks for your info. Meanwhile, I fixed this issue.

What was causing the problem was a Service that needed to be unbound when the Activty was destroyed because of rotation.

As far as I could understand the Fragments are not destroyed when the activity is destroyed. However, I would appreciate any comment on this.

So, I reinitialized the Fragments on the onCreate() method when the Activty is created again after destruction, and this is not causing trouble to the application.

protected void onDestroy() {
   mService.stop();
   stopService(new Intent(this, LocalService.class));
   unbindService(mConnection);
   g.fermaGrab();
   stopService(intent);
   Log.e("ondestroy","passostopService(intent)"); 
   super.onDestroy();       
}

Solution 2:

Just because the other answers to this question led me on a wild goose hunt of WeakReferences, memory leaks, and onResumeFragments... you can get this error simply by having an onFocusChangeListener that tries to pop up a dialog box when a control loses focus. The error comes in ActivityThread.handleRelaunchActivity so it's a little tough to figure out.


Post a Comment for "On Rotation I Get "Unable To Destroy Activity ... Can Not Perform This Action After OnSaveInstanceState""