1

I'm a bit confused really. When it says that

Activities with singleInstance launchmode uses the singleton pattern, and that instance will be the root activity of a new task

When it says new task, does it mean that the launching activity will get executed in a new thread??? Or the android system just uses flags to control activities navigation internally with datastructures within the Main Thread

Tiko
  • 990
  • 7
  • 18

2 Answers2

1

does it mean that the launching activity will get executed in a new thread???

No it does not.

All app's activities (and services and receiver) are executed on a single thread called the main thread.

You can find a good read on the Android threading model here.

Gilad Haimov
  • 5,767
  • 2
  • 26
  • 30
1

Activities with singleInstance launchmode uses the singleton pattern

This is misleading. Activities, whatever the launchmode, should never be considered singletons. True, there is only one instance of the Activity when using singleInstance, but the normal Activity lifecycle still occurs and it is not safe to keep a static reference to any Activity.

When it says new task, does it mean that the launching activity will get executed in a new thread???

No, all Activities live in the main thread and you should only interact with them there. The confusion comes from the usage of the word task, which does not refer to threading in this case. It refers to a group of Activities. There's a useful reference concerning this subject in the official docs.

Krylez
  • 17,414
  • 4
  • 32
  • 41