Android M Camera Intent + permission bug?

I had the same issue and find this doc from google: https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE “Note: if you app targets M and above and declares as using the CAMERA permission which is not granted, then atempting to use this action will result in a SecurityException.” This is really weird. Don’t make sense at all. The app declares Camera … Read more

Check if device has a camera?

This is what I’m using import android.content.pm.PackageManager; PackageManager pm = context.getPackageManager(); if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) { } All sorts of other fun things to test for are available too – the compass, is location available, is there a front facing camera: http://developer.android.com/reference/android/content/pm/PackageManager.html

How do I open the “front camera” on the Android platform?

private Camera openFrontFacingCameraGingerbread() { int cameraCount = 0; Camera cam = null; Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); cameraCount = Camera.getNumberOfCameras(); for (int camIdx = 0; camIdx < cameraCount; camIdx++) { Camera.getCameraInfo(camIdx, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { try { cam = Camera.open(camIdx); } catch (RuntimeException e) { Log.e(TAG, “Camera failed to open: ” + e.getLocalizedMessage()); … Read more

Android camera intent

private static final int TAKE_PICTURE = 1; private Uri imageUri; public void takePhoto(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File photo = new File(Environment.getExternalStorageDirectory(), “Pic.jpg”); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); imageUri = Uri.fromFile(photo); startActivityForResult(intent, TAKE_PICTURE); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case TAKE_PICTURE: if (resultCode == … Read more

Android camera android.hardware.Camera deprecated

API Documentation According to the Android developers guide for android.hardware.Camera, they state: We recommend using the new android.hardware.camera2 API for new applications. On the information page about android.hardware.camera2, (linked above), it is stated: The android.hardware.camera2 package provides an interface to individual camera devices connected to an Android device. It replaces the deprecated Camera class. The … Read more

How to use Android’s camera or camera2 API to support old and new API versions without deprecation notes?

Even though the old camera API is marked as deprecated, it is still fully functional, and will remain so for quite a while (as nearly all camera-using applications on the Play Store use it currently). You’ll have to ignore Android Studio’s complaints about it being deprecated, but if you want to support Android versions earlier … Read more

Android Camera Preview Stretched

I’m using this method -> based on API Demos to get my Preview Size: private Camera.Size getOptimalPreviewSize(List<Camera.Size> sizes, int w, int h) { final double ASPECT_TOLERANCE = 0.1; double targetRatio=(double)h / w; if (sizes == null) return null; Camera.Size optimalSize = null; double minDiff = Double.MAX_VALUE; int targetHeight = h; for (Camera.Size size : sizes) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)