Skip to content Skip to sidebar Skip to footer

"runtimeexception: Performing Pause Of Activity That Is Not Resumed"

(I see a similar question on stackoverflow, but the answer there is not a true answer, and the context of the problem is a bit different too.) 'java.lang.RuntimeException: Performi

Solution 1:

I've just had this problem because I was calling activity.recreate() (or .finish() and .startActivity() - depending on android version). Of course, you would only call those functions because you want to reload language, reset orientation and similar stuff that you can only do with activity recreation.

You can't call those functions (.finish() or .recreate()) from onResume() though. If you do, you will receive the mentioned non-fatal exception.

I "solved" the issue by delaying the .recreate() call for one millisecond so that the activity gets properly resumed and is only then killed.

Handlerhandler=newHandler();
  handler.postDelayed(newRunnable()
  {
    @Overridepublicvoidrun()
    {
      log.i("TX.refresh", "Switching to %s from %s", lang, lang);
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
      {
        ctx.finish();
        ctx.startActivity(ctx.getIntent());
      } else ctx.recreate();
    }
  }, 1);

Solution 2:

Please use this code in your manifest file

<activityandroid:name=".YourActivity"android:configChanges="orientation|keyboardHidden|screenSize"android:screenOrientation="portrait" ></activity>

Post a Comment for ""runtimeexception: Performing Pause Of Activity That Is Not Resumed""