Search code examples
androidandroid-intentonpause

Why does receiving an Intent calls onPause()


According to Android's Activity lifecyle, method Activity.onPause() is called only if another activity calls into the foreground. My application has only one activity which is itself set with android:launchMode="singleTask".

According to the stackstrace below receiving a new Intent triggers Activity.onPause().

Can anyone explain why ?

Stacktrace:

android.app.Activity.performPause(Activity.java:3877)
android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1191)
android.app.ActivityThread.performNewIntents(ActivityThread.java:1736)
android.app.ActivityThread.handleNewIntent(ActivityThread.java:1746)
android.app.ActivityThread.access$2300(ActivityThread.java:117)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:982)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:130)
android.app.ActivityThread.main(ActivityThread.java:3691)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:507)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
dalvik.system.NativeStart.main(Native Method)

Regards,


Solution

  • This behaviour is expected. I looked at the Android source code (v2.3.7) and before receiving an Intent the activity is paused.