Launch default camera app (no return)

I would like to start the camera by default, but I want it to act as if it was launched from the launch panel (i.e. the captured image should be saved by the camera application in the user's gallery, and not returned to my application), If I I use Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); , the camera application uses "OK? Retry?" - The user interface and does not save the image. I would prefer not to use the β€œdirect” com.android.camera intent, because many devices use custom camera apps. I saw that the gallery3d application uses an alias that implements com.android.camera/.Camera , but I’m not sure that every preloaded camera application of the manufacturer does this.

+9
source share
2 answers

Now I implemented it as follows:

 Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); try { PackageManager pm = mContext.getPackageManager(); final ResolveInfo mInfo = pm.resolveActivity(i, 0); Intent intent = new Intent(); intent.setComponent(new ComponentName(mInfo.activityInfo.packageName, mInfo.activityInfo.name)); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(intent); } catch (Exception e){ Log.i(TAG, "Unable to launch camera: " + e); } 
+11
source

This code will do the trick:

 Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); context.startActivity(intent); 
+5
source

Source: https://habr.com/ru/post/887692/


All Articles