I am playing around with Android Q and virtual displays.
(我正在玩Android Q和虚拟显示器。)
I managed to created a VirtualDisplay and I bound it to a SurfaceView:(我设法创建了VirtualDisplay并将其绑定到SurfaceView:)
@Override
(@Override)
protected void onCreate(Bundle savedInstanceState) {
(受保护的void onCreate(Bundle savedInstanceState){)
...
(...)
mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
(mSurfaceView =(SurfaceView)findViewById(R.id.surfaceView);)
mSurfaceView.getHolder().addCallback(this);
(mSurfaceView.getHolder()。addCallback(this);)
}
(})
@Override
(@Override)
public void surfaceCreated(SurfaceHolder holder) {
(public void surfaceCreated(SurfaceHolderholder){)
mDisplayManager = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE);
(mDisplayManager =(DisplayManager)this.getSystemService(Context.DISPLAY_SERVICE);)
mVirtualDisplay = mDisplayManager.createVirtualDisplay(DISPLAY_NAME, 300, 200, mDensity, mSurfaceView.getHolder().getSurface(), VIRTUAL_DISPLAY_FLAGS);(mVirtualDisplay = mDisplayManager.createVirtualDisplay(DISPLAY_NAME,300,200,mDensity,mSurfaceView.getHolder()。getSurface(),VIRTUAL_DISPLAY_FLAGS);)
}
(})
My VirtualDisplay flags are: DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION |
(我的VirtualDisplay标志是:DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION |)
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC(DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC)
I am able to launch the desired activity in the new display using setLaunchDisplayId on my Intent.
(我可以使用Intent上的setLaunchDisplayId在新的显示中启动所需的活动。)
Is it possible to add touch events to this display?
(是否可以在此显示器上添加触摸事件?)
If I do adb shell dumpsys display I got touch NONE .(如果我执行adb shell dumpsys显示,则 触摸NONE 。)
ask by user1638466 translate from so