0

I want to display the app screen on another display( Not a screen mirror). Another display is connected to mobile through USB C3.1 - HDMI. (Like TV, Monitor ). 

While displaying one screen to TV,  Same time I want to use another screen of the app on my mobile. (The Same time 2 screens will be active 1 screen in mobile and another on TV)

Use case example: If I am playing a game, GamePlay view will display on the TV and Gameplay buttons will display on my mobile.

Example: https://www.samsung.com/us/explore/dex/

Please suggest a way to implement such a feature in my android app.

Parth
  • 1,908
  • 1
  • 19
  • 37
  • Use `Presentation` to show content on the external display. – CommonsWare Aug 18 '21 at 10:53
  • @CommonsWare can you please explain a bit more. Thanks – Parth Aug 20 '21 at 03:22
  • You can download [a free older edition of one of my books](https://commonsware.com/Android/Android-8.7-CC.pdf). The "Supporting External Displays" chapter has close to 50 pages on the subject. The samples are a bit out of date, but the core concepts should still be fine. – CommonsWare Aug 20 '21 at 10:45

1 Answers1

0

It is quite late but I hope it can help for others. I can achive that with adb command on termux app.

First, get external display id:

mDisplayId=`adb shell dumpsys display | grep "mDisplayId=" | tail -n 1|cut -d= -f2`

Second, get current app activity

mPackage=`adb shell dumpsys window windows|grep -E "imeInputTarget"|cut -d" " -f9|cut -d/ -f1
mActivity=$(adb shell pm dump $mPackage|grep -A1 MAIN:|grep com.|cut -d" " -f10|sed "s:\\$:\\\\\\$:g")

Third, start app activity on external display

adb shell am start-activity --display $mDisplayId --windowingMode 0 $mActivity

Demo: https://youtu.be/KuXEL6Ugsoc

Loc Huynh
  • 311
  • 2
  • 7