diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e578124..00b9c68 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + diff --git a/app/src/main/java/com/example/cricket/MainActivity.java b/app/src/main/java/com/example/cricket/MainActivity.java index 18415d7..bd6191f 100644 --- a/app/src/main/java/com/example/cricket/MainActivity.java +++ b/app/src/main/java/com/example/cricket/MainActivity.java @@ -3,6 +3,7 @@ import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; +import android.graphics.Camera; import android.graphics.SurfaceTexture; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraCaptureSession; @@ -11,6 +12,8 @@ import android.hardware.camera2.CameraManager; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.params.StreamConfigurationMap; +import android.hardware.usb.UsbDevice; +import android.hardware.usb.UsbManager; import android.media.MediaRecorder; import android.os.Build; import android.os.Environment; @@ -20,6 +23,7 @@ import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.util.Log; import android.util.Size; import android.util.SparseArray; import android.util.SparseIntArray; @@ -39,6 +43,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.HashMap; import java.util.List; public class MainActivity extends AppCompatActivity { @@ -135,7 +140,13 @@ public int compare(Size lhs, Size rhs) { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - + UsbManager m = (UsbManager)getApplicationContext().getSystemService(USB_SERVICE); + HashMap devices = m.getDeviceList(); + Collection ite = devices.values(); + UsbDevice[] usbs = ite.toArray(new UsbDevice[]{}); + for (UsbDevice usb : usbs){ + Toast.makeText(getApplicationContext(), usb.getDeviceName(), Toast.LENGTH_SHORT).show(); + } createVideoFolder(); mMediaRecorder = new MediaRecorder(); @@ -223,9 +234,12 @@ private void setupCamera(int width, int height) { try { for (String cameraId : cameraManager.getCameraIdList()) { CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId); +// Toast.makeText(getApplicationContext(),cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) , Toast.LENGTH_SHORT).show(); + if (cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) { continue; } + Toast.makeText(this, String.valueOf(cameraManager.getCameraIdList().length), Toast.LENGTH_SHORT).show(); StreamConfigurationMap map = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); int deviceOrientation = getWindowManager().getDefaultDisplay().getRotation(); mTotalRotation = sensorToDeviceRotation(cameraCharacteristics, deviceOrientation);