当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Examples of when to use launchMode = "singleInstance"

问题描述:

I am looking for concrete examples of when to use launchMode="singleInstance". Everywhere I read, it is said that there are very few occasions when it should be used. So I'm amazed I never see examples!!

The closest explanation I've found is here where it says:

[it] should only be used in the applications that are implemented entirely as one activity

But if that is the case, I wonder why it is never phrased so concisely in official Android documentation.

So my question is:

  1. Is this really the only case where singleInstance should be used?
  2. Are there any situations where the above is NOT a good enough reason for using singleInstance?
  3. Concrete examples where using singleInstance is a good idea
  4. Undesirable side effects of using singleInstance inappropriately, such as this question

网友答案:

According this article:

Only one AlarmAlert activity at a time and it is always its own task. Anything it might launch (if anything) becomes a part of a separate task stack.

But this information is deprecated. I found that Marshmallow is using com.android.deskclock.timer.TimerAlertFullScreen as an activity with singleInstance launch mode.

<activity
             android:name="com.android.deskclock.timer.TimerAlertFullScreen"
             android:excludeFromRecents="true"
             android:theme="@style/TimerAlertFullScreenTheme"
             android:launchMode="singleInstance"
             android:showOnLockScreen="true"
             android:taskAffinity=""
             android:configChanges="screenSize|keyboardHidden|keyboard|navigation"/>

Here is the link.

分享给朋友:
您可能感兴趣的文章:
随机阅读: