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 launch front camera with intent?

Word of caution: its a hack Add this to the intent intent.putExtra(“android.intent.extras.CAMERA_FACING”, 1); This solution isn’t sustainable, its using a testing code of the Camera app. For more info look at the “getCameraFacingIntentExtras” static method in Util class of the AOSP Camera project. Update: Looks like that it was disabled in L

camera app not working?

You have to unlock the camera before creating MediaRecorder. And lock it before releasing it. Try this code, it will work Have fun… package com.marcodinacci.book.acb; import java.io.IOException; import android.app.Activity; import android.content.pm.ActivityInfo; import android.hardware.Camera; import android.media.MediaRecorder; import android.os.Bundle; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.View.OnClickListener; import android.widget.ToggleButton; public class MediaRecorderRecipe extends Activity implements … Read more

Picture distorted with Camera and getOptimalPreviewSize

I just suffered through the same problem, and came up with a similar but lighter weight solution. I don’t see anything wrong with your saving method though. private Camera.Size getBestPreviewSize(int width, int height) { Camera.Size result=null; Camera.Parameters p = camera.getParameters(); for (Camera.Size size : p.getSupportedPreviewSizes()) { if (size.width<=width && size.height<=height) { if (result==null) { result=size; … Read more

android : camera doesn’t open in marshmallow

So, I accomplished my task like as below: For Checking permission I created a separate class as below: public class MarshMallowPermission { public static final int RECORD_PERMISSION_REQUEST_CODE = 1; public static final int EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE = 2; public static final int CAMERA_PERMISSION_REQUEST_CODE = 3; Activity activity; public MarshMallowPermission(Activity activity) { this.activity = activity; } public boolean … Read more

Make a SurfaceView larger than the screen (Fitting a camera preview to a SurfaceView larger than the display)

First, remove source of crashes: startPreviewCamera called in onResume. Camera preview shall be started in SurfaceHolder.Callback methods. Then you should know that you can set preview size only to sizes reported by Camera.Parameters.getSupportedPreviewSizes. And these sizes will most likely be smaller or equal to device’s screen size. Then you simply call Camera.Parameters p = camera.getParameters(); … Read more

Camera : setDisplayOrientation function is not working for Samsung Galaxy ACE with Android 2.3.6

When I had a similar problem with the original Galaxy Tab running 2.2.1, I was able to solve it by doing the following: Camera.Parameters parameters = camera.getParameters(); parameters.set(“orientation”, “portrait”); parameters.setRotation(90); camera.setParameters(parameters); However, it looks like you may have already tried that exact combination, given that you have identical (but commented out) code above. However, the … Read more

Take photo from camera in fragment

Hope this will help you: public class CameraImage extends Fragment { private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 1888; Button button; ImageView imageView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.camera_image, container, false); button = (Button) rootView.findViewById(R.id.button); imageView = (ImageView) rootView.findViewById(R.id.imageview); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) … Read more

Fitting a camera preview to a SurfaceView larger than the display

Ok, I know this is very late as an answer but it is possible. Below is code from the Android SDK sample. To see the rest of the code to implement this download the android sdk samples and go to Samples/android-10(one I used, could try whichever you want to target)/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.java class PreviewSurface extends ViewGroup implements … Read more

Media Recorder with Google Vision API

Solution 1: From Android Lollipop, a MediaProjection API was introduced which in conjunction with MediaRecorder can be used to save a SurfaceView to a video file. This example shows how to output a SurfaceView to a video file. Solution 2: Alternatively, you can use one of the neat Encoder classes provided in the Grafika repository. … Read more