I want to start the camera app to get the photo, but when I click ok, the camera app is still in the foreground and my activity cannot resume.
That's what I'm doing:
File file = new File(getFilesDir() + File.separator + UUID.randomUUID().toString() + ".jpg"); try { file.createNewFile(); } catch (IOException e) { Toast.makeText(this, R.string.problem_creating_file, Toast.LENGTH_LONG).show(); return; } Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); takePhotoIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivityForResult(takePhotoIntent, REQUEST_CODE_PHOTO);
And in the manifest:
<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" />
I found many solutions on the Internet, but no one worked for me :(
android android camera
Daniele vitali
source share