Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
601 views
in Technique[技术] by (71.8m points)

android - Android Q VirtualDisplay触摸输入事件(Android Q VirtualDisplay touch input events)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...