Closed ravi2611gupta closed 1 year ago
I can't reduce this question.
I have resolved the second problem "Select the resolution" but I am stuck on the first one "Restarting the app". I think it is not a good UX that users have to restart the app after granting permission.
I want to resolve this issue. I just want to show the preview immediately when a user grants permission. I tried it but it is not working. Please let me show you the code.
`private UVCCameraHelper.OnMyDevConnectListener listener = new UVCCameraHelper.OnMyDevConnectListener() {
@Override
public void onAttachDev(UsbDevice device) {
// request open permission
if (!isRequest) {
isRequest = true;
if (mCameraHelper != null) {
mCameraHelper.requestPermission(0);
isPreview = true;
onConnectDev(device, true);
}
}
}
@Override
public void onDettachDev(UsbDevice device) {
// close camera
if (isRequest) {
isRequest = false;
mCameraHelper.closeCamera();
showShortMsg(device.getDeviceName() + " is out");
}
}
@Override
public void onConnectDev(UsbDevice device, boolean isConnected) {
handleDeviceConnection(device, isConnected);
}
private void handleDeviceConnection(UsbDevice device, boolean isConnected) {
if (!isConnected) {
showShortMsg("fail to connect,please check resolution params");
isPreview = false;
} else {
mCameraHelper.startPreview(mUVCCameraView);
isPreview = true;
showShortMsg("connecting");
// initialize seekbar
// need to wait UVCCamera initialize over
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
e.printStackTrace();
}
Looper.prepare();
mCameraHelper.updateResolution(1280, 960);
if(mCameraHelper != null && mCameraHelper.isCameraOpened()) {
mSeekBrightness.setProgress(mCameraHelper.getModelValue(UVCCameraHelper.MODE_BRIGHTNESS));
mSeekContrast.setProgress(mCameraHelper.getModelValue(UVCCameraHelper.MODE_CONTRAST));
}
Looper.loop();
}
}).start();
}
}
@Override
public void onDisConnectDev(UsbDevice device) {
showShortMsg("disconnecting");
}
};
`
please help me out it is really important. I just want to show the preview immediately when a user grants permission. I tried it but it is not working.
please help me out it is really important. I just want to show the preview immediately when a user grants permission. I tried it but it is not working.
I really don't know how to position the problem, I think you can check the initiate route?
Good news! You can modify the USBMonitor.java(178), like this: //Build.VERSION.SDK_INT <= 30 ? 0 : PendingIntent.FLAG_IMMUTABLE); 0);
When I am attaching the OTG camera device I am not able to see the output of that camera and I have to do 2 things to see the output
and I want to get rid of this problem I want that as I attach the device the output will show on my screen.