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

How to capture an image and store it with the native Android Camera

Here was the final product in case anyone is still visiting this thread: public class CameraCapture extends Activity { protected boolean _taken = true; File sdImageMainDirectory; protected static final String PHOTO_TAKEN = “photo_taken”; @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); File root = new File(Environment .getExternalStorageDirectory() + File.separator + “myDir” + File.separator); root.mkdirs(); … 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>

setRotation(90) to take picture in portrait mode does not work on samsung devices

I try to answer this in relation to the Exif tag. This is what I did: Bitmap realImage = BitmapFactory.decodeStream(stream); ExifInterface exif=new ExifInterface(getRealPathFromURI(imagePath)); Log.d(“EXIF value”, exif.getAttribute(ExifInterface.TAG_ORIENTATION)); if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase(“6”)){ realImage=ImageUtil.rotate(realImage, 90); }else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase(“8”)){ realImage=ImageUtil.rotate(realImage, 270); }else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase(“3”)){ realImage=ImageUtil.rotate(realImage, 180); } The ImageUtil.rotate(): public static Bitmap rotate(Bitmap bitmap, int degree) { int w = bitmap.getWidth(); int h = … Read more

How to capture image from custom CameraView in Android?

try to use Surface View for creating dynamic camera view and set in your required portion. following code try variables set Class level (Global) Button btn_capture; Camera camera1; SurfaceView surfaceView; SurfaceHolder surfaceHolder; public static boolean previewing = false; Following code in onCreate() method getWindow().setFormat(PixelFormat.UNKNOWN); surfaceView = new SurfaceView(this); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); btn_capture = … Read more

Widget for turning on/off camera flashlight in android

After a long time, I got free to solve this problem. Here is what I did. FlashlightWidgetProvider class : public class FlashlightWidgetProvider extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Intent receiver = new Intent(context, FlashlightWidgetReceiver.class); receiver.setAction(“COM_FLASHLIGHT”); receiver.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, receiver, 0); RemoteViews views = new … Read more

Android open camera from button

To call the camera you can use: Intent intent = new Intent(“android.media.action.IMAGE_CAPTURE”); startActivity(intent); The image will be automatically saved in a default directory. And you need to set the permission for the camera in your AndroidManifest.xml: <uses-permission android:name=”android.permission.CAMERA”> </uses-permission>

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

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