我没有使用Fragment,我正在使用AppCompatActivity
并显示共享元素工作正常但我在这一行面临崩溃
// For Shared Element Animation same in both back press(hardware & app Bar)
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return false;
}
崩溃报告
Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(Unknown Source:1493)
at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(Unknown Source:584)
at android.support.v4.app.FragmentActivity.onBackPressed(Unknown Source:189)
at android.app.Activity.onKeyUp(Activity.java:2199)
at android.view.KeyEvent.dispatch(KeyEvent.java:2664)
at android.app.Activity.dispatchKeyEvent(Activity.java:2441)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(Unknown Source:524)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(Unknown Source:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(Unknown Source:241)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1996)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3909)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3883)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3416)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3466)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3435)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3542)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3443)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3599)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3416)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3466)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3435)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3443)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3416)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3466)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3435)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3575)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3759)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2056)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1750)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1741)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2033)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:138)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:5380)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:970)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786)
at dalvik.system.NativeStart.main(NativeStart.java)