Good I am trying to launch an intent to visualize an external camera through usb, the thing is that I do not hit the key, since everything related that I have found is on the mobile's own camera .. my question is if there is any way of throwing the external camera through the usb port, thanks
Hello again I have managed to open the two cameras of the mobile and save the photos, on the external USB camera I have managed to recognize the usb but I do not know how to say it is a camera and that is what you use.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//mInfo = (ImageView) findViewById(R.id.imageview);
cameraButton = (Button) findViewById(R.id.button_image);
gallery = (Button) findViewById(R.id.button_gallery);
imageView = (ImageView) findViewById(R.id.imageview);
mLogger = new Logger(this);
mLogger.setMode(Logger.MODE_TOAST);
mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
usbConnection();
mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
registerReceiver(mUsbReceiver, filter);
mUsbManager.requestPermission(device, mPermissionIntent);
UsbInterface intf = device.getInterface(0);
UsbEndpoint endpoint = intf.getEndpoint(0);
UsbDeviceConnection connection = mUsbManager.openDevice(device);
connection.claimInterface(intf, forceClaim);
//creo que falla aquí abajo,en bytes, como podría hacerlo en otro hilo?
connection.bulkTransfer(endpoint,bytes, bytes.length, TIMEOUT);//do in another thread
mLogger.log("usb", "//////////////////////////////////////: " + mCameraId);
// Servicio USB --> Definirlo como Cámara (Añadir Cámara)
//CameraManager manager = (CameraManager) mUsbManager;
CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameraList = manager.getCameraIdList();
} catch (CameraAccessException e) {
e.printStackTrace();
}
if (manager != null) {
try {
for (String mCameraId : manager.getCameraIdList()) {
CameraCharacteristics cameraCharacteristics = manager.getCameraCharacteristics(mCameraId);
mLogger.log("usb", "//////////////////////////////////////: " + mCameraId);
manager.openCamera(mCameraId, mStateCallback, null);
}
} catch (CameraAccessException e) {
e.printStackTrace();
}
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
cameraButton.setEnabled(false);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
}
}
}