Android 11 (R) return empty list when querying intent for ACTION_IMAGE_CAPTURE

Android 11 changes how apps can query and interact with other apps. From the docs: The PackageManager methods that return results about other apps, such as queryIntentActivities(), are filtered based on the calling app’s <queries> declaration. So you need to declare <queries> in your AndroidManifest.xml: <manifest package=”com.example”> <queries> <intent> <action android:name=”android.media.action.IMAGE_CAPTURE” /> </intent> </queries> … … Read more

How to get Image Path just captured from camera

This works for me… Code: Uri selectedImageUri = data.getData(); selectedImagePath = getRealPathFromURI(selectedImageUri); Method: getRealPathFromURI() //—————————————- /** * This method is used to get real path of file from from uri * * @param contentUri * @return String */ //—————————————- public String getRealPathFromURI(Uri contentUri) { try { String[] proj = {MediaStore.Images.Media.DATA}; Cursor cursor = managedQuery(contentUri, proj, … Read more

Take a photo automatically without user interaction

Android does not allow you to take picture without showing the preview window. So you have to make the surface view very small. Like 1*1 pixel and put it in a corner of any control. Or show a dummy surface view to do this. SurfaceView view = new SurfaceView(this); c.setPreviewDisplay(view.getHolder()); c.startPreview(); c.takePicture(shutterCallback, rawPictureCallback, jpegPictureCallback); Check … Read more

android: Take camera picture without “save” / “delete” confirmation

You ca use the SurfaceView to capture image package com.camera; import java.io.IOException; import android.app.Activity; import android.content.Intent; import android.hardware.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; import android.widget.Toast; public class Camera_capture extends Activity implements SurfaceHolder.Callback { private Camera mCamera; private SurfaceView surfaceView; private SurfaceHolder surfaceHolder; private Button capture_image; @Override protected void … Read more

Picture taken with camera intent is low quality on ImageView (7.0+) [duplicate]

If you are asking “how do I get a full-resolution image?”, supply EXTRA_OUTPUT on the ACTION_IMAGE_CAPTURE Intent, then look at that location for the image when onActivityResult() is called with RESULT_OK for your request. This sample app illustrates the technique, using FileProvider for better compatibility on Android 7.0+: /*** Copyright (c) 2008-2017 CommonsWare, LLC Licensed … Read more

android camera : Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity

Make sure you have both Camera Permission and READ/WRITE External Storage Permissions. Try this is working like charm with me private String selectedImagePath = “”; final private int PICK_IMAGE = 1; final private int CAPTURE_IMAGE = 2; public Uri setImageUri() { // Store image in dcim File file = new File(Environment.getExternalStorageDirectory() + “/DCIM/”, “image” + … Read more

Android – Save images in an specific folder

Go through the following code , its working fine for me. private void createDirectoryAndSaveFile(Bitmap imageToSave, String fileName) { File direct = new File(Environment.getExternalStorageDirectory() + “/DirName”); if (!direct.exists()) { File wallpaperDirectory = new File(“/sdcard/DirName/”); wallpaperDirectory.mkdirs(); } File file = new File(“/sdcard/DirName/”, fileName); if (file.exists()) { file.delete(); } try { FileOutputStream out = new FileOutputStream(file); imageToSave.compress(Bitmap.CompressFormat.JPEG, 100, … Read more

Activity killed / onCreate called after taking picture via intent

Actually the camera causes the orientation change in your activity that is why your activity is being destroyed and recreated. Add this in your manifest file it will prevent the orientation change and your activity will not get destroyed and recreated. <activity android:name=”.YourActivity” android:configChanges=”orientation|keyboardHidden|screenSize” android:screenOrientation=”portrait” > </activity>