For a singleTop activity, the previous instance is reused, even though the activity was not at top of the stack

`The LauncherActivity is the first screen in Homescreen. I am tyring to understand if singleTop or singleTask would be the right launchmode.
The idea is to avoid creating muktiple acitivty instances in all transitions to Homescreen.

The activity configuration in Manifest is –

<activity
    android:name=".ui.LauncherActivity"
    android:clearTaskOnLaunch="true"
    android:exported="true"
    android:stateNotNeeded="true"
    android:launchMode="singleTop">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.LAUNCHER_APP" />
    </intent-filter>
</activity>

The activity can be triggered only from a non-acitivty application, which belongs to a different package from LauncherActivity. It is launched like below-

private void startHomeActivity() {
    Intent intent = new Intent();
    intent.setAction(Constants.ACTION_MAIN);
    intent.addCategory(Constants.CATEGORY_LAUNCHER);
    intent.setComponent(new ComponentName(Constants.HOME_PACKAGE_NAME,
            Constants.HOME_ACTIVITY_CLASS_NAME));
    mContext.startActivityAsUser(intent, UserHandle.CURRENT);
}

Observation:
Currently singleTop is set as launchmode for the LauncherActivity. Please note that, AppDrawerActivity is another acitivty, which belong to Homescreen application package.

The transition is done as below-

  1. Reboot the system, current screen is Homescreen(LauncherActivity).
  2. Switch to AppDrawerActivity
  3. Switch to HVAC application from AppDrawerActivity

at this point the activity dump shows the stack as below. Here, we can see that in task#1200003, AppDrawerActivity is on the top of the stack.
Task display areas in top down Z order: TaskDisplayArea DefaultTaskDisplayArea mPreferredTopFocusableRootTask=Task{82141e #1200004 type=standard A=1210072:com.apps.hvac U=12 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1} mLastFocusedRootTask=Task{82141e #1200004 type=standard A=1210072:com.apps.hvac U=12 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1} Application tokens in top down Z order: * Task{82141e #1200004 type=standard A=1210072:com.apps.hvac U=12 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1} bounds=[0,0][1280,720] * ActivityRecord{63ba8ca u12 com.apps.hvac/.ui.HvacLandingActivity t1200004} * Task{57a2911 #1 type=home ?? U=0 visible=false visibleRequested=false mode=fullscreen translucent=true sz=2} bounds=[0,0][1280,720] * Task{4bd5acd #1200003 type=home A=1201000:com.apps.homescreen U=12 rootTaskId=1 visible=false visibleRequested=false mode=fullscreen translucent=true sz=2} bounds=[0,0][1280,720] * ActivityRecord{34c92b u12 com.apps.homescreen/.ui.AppDrawerActivity t1200003} * ActivityRecord{d1d210e u12 com.apps.homescreen/.ui.LauncherActivity t1200003} * Task{4089178 #2 type=home A=10132:com.android.car.provision U=0 rootTaskId=1 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1} bounds=[0,0][1280,720] * ActivityRecord{6be6283 u0 com.android.car.provision/.DefaultActivity t2}

The we click on Home button, which is handled in a different non-acitivty application. Now the stack looks as below.

Task display areas in top down Z order: TaskDisplayArea DefaultTaskDisplayArea mPreferredTopFocusableRootTask=Task{57a2911 #1 type=home ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2} mLastFocusedRootTask=Task{57a2911 #1 type=home ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2} Application tokens in top down Z order: * Task{57a2911 #1 type=home ?? U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=2} bounds=[0,0][1280,720] * Task{4bd5acd #1200003 type=home A=1201000:com.apps.homescreen U=12 rootTaskId=1 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1} bounds=[0,0][1280,720] * ActivityRecord{d1d210e u12 com.apps.homescreen/.ui.LauncherActivity t1200003} * Task{4089178 #2 type=home A=10132:com.android.car.provision U=0 rootTaskId=1 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1} bounds=[0,0][1280,720] * ActivityRecord{6be6283 u0 com.android.car.provision/.DefaultActivity t2} * Task{82141e #1200004 type=standard A=1210072:com.apps.hvac U=12 visible=false visibleRequested=false mode=fullscreen translucent=true sz=1} bounds=[0,0][1280,720] * ActivityRecord{63ba8ca u12 com.apps.hvac/.ui.HvacLandingActivity t1200004}

**Could anyone please help to understand these points?

  1. As per the document, when a singleTop acitivty is started, if it is not at the top of the task, it should be recreated. In this case,
    AppDrawerActivity was at the top of task. But still why the previous instance of LauncherActivity was reused instead of recreating it?

  2. In this case which launchmode would be ideal in between singleTop and singleTask?**

`

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật