diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 7b383d452dbdc..a6d2be0842a78 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -5580,6 +5580,9 @@ public class Activity extends ContextThemeWrapper if (mParent != null) { throw new IllegalStateException("Can only be called on top-level activity"); } + if (Looper.myLooper() != mMainThread.getLooper()) { + throw new IllegalStateException("Must be called from main thread"); + } mMainThread.scheduleRelaunchActivity(mToken); }