我从此链接下载了“ usb-serial-for-android”示例应用程序。
https://github.com/mik3y/usb-serial-for-android
主屏幕显示usb设备,单击该设备时移至第二屏幕以读取usb发送的数据。在该屏幕中,我添加了使用媒体投影和SurfaceView显示摄像机和屏幕录像的功能。
问题:首次打开应用程序时,移至第二个屏幕时,调用 ActivityCompat.requestPermissions 以获得运行时权限。在权限弹出期间,第二个活动消失,并且权限对话框出现在第一个屏幕上。
我用谷歌搜索并尝试了各种可能性,但无法解决问题。不知道如何避免第二个屏幕消失。为摄像头和屏幕录制创建了单独的应用程序,效果很好。我在两天后被屏蔽了此问题。
谢谢。
我尝试开始屏幕录制时的日志
2019-05-07 15:42:35.251 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@2c5f603[SerialConsoleActivity]: ViewPostImeInputStage processPointer 0
2019-05-07 15:42:35.372 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@2c5f603[SerialConsoleActivity]: ViewPostImeInputStage processPointer 1
2019-05-07 15:42:35.377 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setAudioSource(1)
2019-05-07 15:42:35.381 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setVideoSource(2)
2019-05-07 15:42:35.384 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setVideoSize(1024, 768)
2019-05-07 15:42:35.385 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setVideoEncoder(2)
2019-05-07 15:42:35.385 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setAudioEncoder(1)
2019-05-07 15:42:35.386 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setParameter()
2019-05-07 15:42:35.386 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setVideoFrameRate(30)
2019-05-07 15:42:35.388 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setParameter()
2019-05-07 15:42:35.394 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: setOutputFile
2019-05-07 15:42:35.395 9546-9546/com.hoho.android.usbserial.examples I/MediaRecorderJNI: prepare
2019-05-07 15:42:35.611 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@2c5f603[SerialConsoleActivity]: MSG_WINDOW_FOCUS_CHANGED 0
2019-05-07 15:42:35.617 9546-9546/com.hoho.android.usbserial.examples I/SerialConsoleActivity: Stopping io manager ..
2019-05-07 15:42:35.617 9546-9546/com.hoho.android.usbserial.examples I/SerialInputOutputManager: Stop requested
2019-05-07 15:42:35.617 9546-9546/com.hoho.android.usbserial.examples D/UsbDeviceConnectionJNI: close
2019-05-07 15:42:35.627 9546-11208/com.hoho.android.usbserial.examples I/SerialInputOutputManager: Stopping mState=STOPPING
2019-05-07 15:42:35.627 9546-11208/com.hoho.android.usbserial.examples I/SerialInputOutputManager: Stopped.
2019-05-07 15:42:35.685 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@d1c48c5[DeviceListActivity]: Relayout returned: oldFrame=[0,0][1024,768] newFrame=[0,0][1024,768] result=0x7 surface={isValid=true -2009718784} surfaceGenerationChanged=true
2019-05-07 15:42:35.686 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@d1c48c5[DeviceListActivity]: mHardwareRenderer.initialize() mSurface={isValid=true -2009718784} hwInitialized=true
2019-05-07 15:42:35.735 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@d1c48c5[DeviceListActivity]: MSG_WINDOW_FOCUS_CHANGED 1
2019-05-07 15:42:35.736 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@d1c48c5[DeviceListActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -2009718784}
2019-05-07 15:42:35.739 9546-9546/com.hoho.android.usbserial.examples V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@7f4afc5 nm : com.hoho.android.usbserial.examples ic=null
2019-05-07 15:42:35.739 9546-9546/com.hoho.android.usbserial.examples I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
2019-05-07 15:42:35.755 9546-9546/com.hoho.android.usbserial.examples D/InputTransport: Input channel constructed: fd=124
2019-05-07 15:42:35.755 9546-9546/com.hoho.android.usbserial.examples D/InputTransport: Input channel destroyed: fd=110
2019-05-07 15:42:35.783 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@d1c48c5[DeviceListActivity]: Relayout returned: oldFrame=[0,0][1024,768] newFrame=[0,0][1024,768] result=0x1 surface={isValid=true -2009718784} surfaceGenerationChanged=false
2019-05-07 15:42:35.796 9546-9546/com.hoho.android.usbserial.examples D/SurfaceView: Relayout returned: oldFrame=[682,531][1024,768] newFrame=[682,531][1024,768] result=0x5 surface={Surface(name=null)/@0xcea0dac isValid=false 0}
2019-05-07 15:42:36.179 9546-9574/com.hoho.android.usbserial.examples D/OpenGLRenderer: endAllActiveAnimators on 0x88daca80 (InsetDrawable) with handle 0x8be7f0e0
2019-05-07 15:42:36.187 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@2c5f603[SerialConsoleActivity]: mHardwareRenderer.destroy()#1
2019-05-07 15:42:36.203 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@2c5f603[SerialConsoleActivity]: Relayout returned: oldFrame=[0,0][1024,768] newFrame=[0,0][1024,768] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
2019-05-07 15:42:36.205 9546-10879/com.hoho.android.usbserial.examples D/DeviceListActivity: Refreshing device list ...
2019-05-07 15:42:36.275 9546-9546/com.hoho.android.usbserial.examples I/SerialConsoleActivity: MediaProjection Stopped
2019-05-07 15:42:36.318 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@2c5f603[SerialConsoleActivity]: mHardwareRenderer.destroy()#4
2019-05-07 15:42:36.318 9546-9546/com.hoho.android.usbserial.examples D/ViewRootImpl@2c5f603[SerialConsoleActivity]: dispatchDetachedFromWindow
2019-05-07 15:42:36.325 9546-9546/com.hoho.android.usbserial.examples D/InputTransport: Input channel destroyed: fd=104
2019-05-07 15:42:37.221 9546-10879/com.hoho.android.usbserial.examples D/DeviceListActivity: + com.hoho.android.usbserial.driver.FtdiSerialDriver@d6127d: 1 port
2019-05-07 15:42:37.225 9546-9546/com.hoho.android.usbserial.examples D/DeviceListActivity: Done refreshing, 1 entries found.