Resume the Top Activity instead of starting the Launcher Activity

前端 未结 6 1227
既然无缘
既然无缘 2020-12-13 09:23

I have two activities in My application, one being launcher and the other is launched as a explicit call from the first.

Here My problem is when i go back to home sc

6条回答
  •  臣服心动
    2020-12-13 09:33

    Try using the following code in the onCreate method of the activity that is specified as the Launcher Activity in the Manifest, i.e. the ContentDownload activity from the original code posted in the question:

    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
      finish();
      return;
    }
    

    This will finish your Launcher Activity before it is displayed by detecting that there is already a task running, and your app should instead resume to the last visible Activity.

    See this page in the Android documentation regarding Android Manifest launchModes: http://developer.android.com/reference/android/R.styleable.html#AndroidManifestActivity_launchMode

提交回复
热议问题