Forum Discussion
More control over the placement of activities on the screens
Hello again. I'm in the process of adapting my launcher app for the Surface Duo. My idea is to use the left screen as the primary screen and the right screen as the secondary screen (it will display the drawer). In general it works well, but I have two problems:
1. I want to make applications always run on the secondary screen. I tried using the Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT flag, but it doesn't always give the right result (I guess because the launcher itself takes up both screens).
2. I would like to make the launcher adapt the interface depending on which screen the other application is running on (roughly like Microsoft Launcher does with the dock). But I don't see an API that lets me know which screen is currently occupied by another application.
2 Replies
- khalper
Microsoft
Hi Evgeny, thanks for your questions!
- Like you guessed, the Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT flag produces different results depending on what is currently shown in each screen - you can read more about this in the documentation or check out our sample. In Android 12L, the behavior of the flag will be updated for large screens as described in this blog post. Unfortunately, at the moment, there is no way to always make sure an intent is launched on the second screen.
- You can use the Jetpack Window Manager library to access the window metrics for an activity and check its bounding rectangle - however, this won't tell you about where other applications/activities are located. Unfortunately, it is also not currently possible to find out information about where other applications are running.
If any new APIs are created in the future to address these issues, we will be sure to let you know!
- EvgenyZobninCopper ContributorOk. Thanks for response.