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:
      <activity
          android:name=".SingleTaskActivity"
          android:label="singleTask launchMode"
          android:launchMode="singleTask"
          android:taskAffinity="">
      
      • 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?
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,501评论 0 23
  • 在古代的一座小山村中有这么一对夫妇,他们迟迟没有孩子,后来丈夫秀树发现妻子不能生育,于是秀树便问绿子为什么瞒着他,...
    天海佑希阅读 4,084评论 0 5
  • 喜欢文章,便尝试着写出属于自己风格的文章,可能是随笔,可能是日记,也可能是生活中的些许收获。 最近发现一个关于...
    程末1阅读 3,424评论 2 2
  • 2017年保持全年早起(冬季6:30, 夏季6:00)和每周5天以上的运动量。今年的重点在事业:完成知识的系统性升...
    SusanKuang阅读 6,156评论 13 41
  • 湖边散步看见有人拍摄婚纱照,凑近一看,幸运的女孩,那么胖都嫁出去了!
    杨知行阅读 1,810评论 0 0

友情链接更多精彩内容