3

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
Community
  • 1
  • 1
Jodes
  • 14,118
  • 26
  • 97
  • 156

1 Answers1

1

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.

Alex
  • 419
  • 1
  • 5
  • 24