diff --git a/app/build.gradle b/app/build.gradle index a32ac10..b873162 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ android { buildToolsVersion "26.0.1" defaultConfig { applicationId "com.jiangdg.usbcamera" - minSdkVersion 18 + minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" @@ -29,6 +29,4 @@ dependencies { compile project(':libusbcamera') compile 'com.jakewharton:butterknife:8.8.1' compile 'com.jakewharton:butterknife-compiler:8.8.1' - compile 'com.jakewharton:butterknife:8.8.1' - compile 'com.jakewharton:butterknife-compiler:8.8.1' } diff --git a/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java b/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java index 2b2d6c5..0ecf3b9 100644 --- a/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java +++ b/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java @@ -47,15 +47,18 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog private boolean isRequest; - // USB设备监听器 + /** + * USB设备事件监听器 + * */ private USBCameraManager.OnMyDevConnectListener listener = new USBCameraManager.OnMyDevConnectListener() { + // 插入USB设备 @Override public void onAttachDev(UsbDevice device) { if(mUSBManager == null || mUSBManager.getUsbDeviceCount() == 0){ showShortMsg("未检测到USB摄像头设备"); return; } - + // 请求打开摄像头 if(! isRequest){ isRequest = true; if(mUSBManager != null){ @@ -64,23 +67,27 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog } } + // 拔出USB设备 @Override public void onDettachDev(UsbDevice device) { if(isRequest){ + // 关闭摄像头 isRequest = false; mUSBManager.closeCamera(); showShortMsg(device.getDeviceName()+"已拨出"); } } + // 连接USB设备成功 @Override public void onConnectDev(UsbDevice device) { - // 处理连接到设备后的逻辑 + } + // 与USB设备断开连接 @Override public void onDisConnectDev(UsbDevice device) { - // 处理与设备断开后的逻辑 + } }; private FileOutputStream fos; diff --git a/libusbcamera/build.gradle b/libusbcamera/build.gradle index ae16b05..84bf920 100644 --- a/libusbcamera/build.gradle +++ b/libusbcamera/build.gradle @@ -5,7 +5,7 @@ android { buildToolsVersion "26.0.1" defaultConfig { - minSdkVersion 18 + minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" diff --git a/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java b/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java index 7774df0..dad39e8 100644 --- a/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java +++ b/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java @@ -7,7 +7,6 @@ import android.hardware.usb.UsbDevice; import android.os.Environment; import com.jiangdg.libusbcamera.R; -import com.serenegiant.usb.CameraDialog; import com.serenegiant.usb.DeviceFilter; import com.serenegiant.usb.USBMonitor; import com.serenegiant.usb.common.AbstractUVCCameraHandler;