Forum Discussion

ShadowyLynx1866's avatar
7 months ago
Solved

Can't stack anymore activities in Panel in immersive

Hi,

on v74 it was simple to stack activities into an immersive Panel (just start new activites from the one in the panel). With the v76 it doesn't behave like that anymore, it opens new activities in the home environment. 

Since v74 is based on Android 12 and v76 on Android 14, I assume launching activities on top of the other in a panel may have changed. Sadly couldn't find the solution, nor any clear documentations. 

Can somebody give me a hint 😉 

 

Thx in advance.

  • Hi!

    Thanks for flagging this! We are investigating, and we will get back to you.

  • Ok. I found myself a solution. So to everyone who wants to stack activities inside a panel in immersive mode just do as follow. 

    1. Retrieve the android displayId of the panel you want to use to stack activities:

    Didn't find a proper way to do it (especially if you have multiple panels), but a way to do it is to look up for display names starting with "VirtualDevice". If you are using only one panel get the virtual displayId of the panel:

    (getSystemService(Context.DISPLAY_SERVICE) as DisplayManager).displays.firstOrNull { it.name.contains("VirtualDevice") }

    Then when you need to stack a new activity to the panel add some options to 'startActivity' method:

    val options: ActivityOptions = ActivityOptions.makeBasic().setLaunchDisplayId(panelDisplayId)
    startActivity(yourIntent, options.toBundle())

    By doing so, activities will stack up onto the ones on your panel.

    If someone has a better and proper solution, please feel free to add here your solution.

    Also, people at Meta you should provide this trick on your documentation. It would help a lot of developer.

    Thx.

7 Replies

  • Hi!

    Thanks for flagging this! We are investigating, and we will get back to you.

    • ShadowyLynx1866's avatar
      ShadowyLynx1866
      Explorer

      Bulkywallnut here a little project that illustrates the issue -> TestImmersif.zip 

      In this project: ActivityA is launched in a panel in ImmersiveActivity. I'd like to open ActivityB on top of ActivityA within the panel of ImmersiveActivity. (The idea is to reuse a complete android app within a panel in an immersive world).

      It does not work, it opens Activity B in a 2D panel outside the Immersive Activity.

      I hope this little project will help you investigate.

  • Ok. I found myself a solution. So to everyone who wants to stack activities inside a panel in immersive mode just do as follow. 

    1. Retrieve the android displayId of the panel you want to use to stack activities:

    Didn't find a proper way to do it (especially if you have multiple panels), but a way to do it is to look up for display names starting with "VirtualDevice". If you are using only one panel get the virtual displayId of the panel:

    (getSystemService(Context.DISPLAY_SERVICE) as DisplayManager).displays.firstOrNull { it.name.contains("VirtualDevice") }

    Then when you need to stack a new activity to the panel add some options to 'startActivity' method:

    val options: ActivityOptions = ActivityOptions.makeBasic().setLaunchDisplayId(panelDisplayId)
    startActivity(yourIntent, options.toBundle())

    By doing so, activities will stack up onto the ones on your panel.

    If someone has a better and proper solution, please feel free to add here your solution.

    Also, people at Meta you should provide this trick on your documentation. It would help a lot of developer.

    Thx.

→ Find helpful resources to begin your development journey in Getting Started

→ Get the latest information about HorizonOS development in News & Announcements.

→ Access Start program mentor videos and share knowledge, tutorials, and videos in Community Resources.

→ Get support or provide help in Questions & Discussions.

→ Show off your work in What I’m Building to get feedback and find playtesters.

→ Looking for documentation?  Developer Docs

→ Looking for account support?  Support Center

→ Looking for the previous forum?  Forum Archive

→ Looking to join the Start program? Apply here.

 

Recent Discussions