Android Tip : think more about Android launchmode

about launchmode

standard

  • one application
    • the same task
    • add new instance on top
  • multiple application
    • before Lollipop
      • in the caller task
      • add new instance on top
    • since Lollipop
      • target application non existed
        • created a new task , create a new activity instance on top
      • target application task existed
        • create a new activity instance on top of the existed task for the application

singleTop

  • one application
    • the same activity instance on top
      • onNewIntent() it
    • the same activity instance non on top
      • create a new activity instance on top
  • multiple application
    • before Lollipop
      • the same activity instance on top of the caller task
        • onNewIntent() it
      • the same activity instance non on top of the caller task
        • create a new activity instance on the caller task
    • since Lollipop
      • target application task existed
        • the same activity instance on top of the target application task
          • onNewIntent() it
        • the same activity instance non on top of the target application task
          • create a new activity instance on top of the target application task
      • target application task non existed
        • create target application task , create a new activity instance on top of the task

singleTask

  • one application
    • exist activity isntance in the task
      • make it on top of the stack
      • onNewIntent() it
      • destroy activity instances above the the singleTask activity instance (liferecycle)
    • non exist activity instance in the task
      • within taskAffinity
        like this:
      
      
      • create a new task
      • create a new activity instance on top of the new task
      • without taskAffinity
        • create a new activity instance on top of the caller task
  • multiple application
    • exist activity instance in system
      • put the task which stacked the activity isntance on top of all tasks
      • remove the activity instances above the singleTask activity instance (liferecycle)
      • onNewIntent() it
    • non exist activity instance in system
      • create a new task
      • put the new task on the top of all tasks
      • create a new activity instance on the top of the new task

singleInstance

  • exist activity instance in system
    • onNewIntent() it
  • non exist activity instance in system
    • create a new task
    • create a new activity instance on top of new task
    some weird appearance
    without taskAffinity attributes, we can only see the top task in the Task Manger, but there're multipul tasks in background.
    within taskAffinity attributes, things seems normal.

I still have questions:

  • Does an application have a special task?
  • How to switch in different tasks?
    • task manager?
    • dumpsys command?
    • relaunch the application icon in launcher?
    • press back button in some cases?

你可能感兴趣的:(Android Tip : think more about Android launchmode)