Is there any way to have one and only one instance of each activity?

后端 未结 8 1398
没有蜡笔的小新
没有蜡笔的小新 2020-12-08 06:41

I\'m finding that in my application, the user can get quite \'nested\' in the various activities that are opened while the user is using the application.

For example

8条回答
  •  时光说笑
    2020-12-08 07:25

    This is your flag! http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_REORDER_TO_FRONT

    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
    

    Note the 'addFlags'. Also note that, onCreate will not be called on this Activity when a new Intent is delivered to it. It will be delivered via the onNewIntent().

    This does not ensure that there is a single instance of the Activity running. To ensure that, check this out: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

提交回复
热议问题