I hope this isn't a duplicate question but I am making an app that I want a button to open the camera app (the default android camera separately). How do I got about doing that? I know there is a function:
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE)
Do I need to use that? And how do I call the button from the xml file?
Also do I need to worry about storing that picture or video or will the default camera app take care of that?
Intent intent = new Intent("android. media. action. IMAGE_CAPTURE"); startActivity(intent);
All you need to do is double-press the power button. If your device supports it, the camera will immediately launch. This works from anywhere.
Intent camera_intent = new Intent(MediaStore. ACTION_IMAGE_CAPTURE); startActivityForResult(camera_intent, pic_id); Now use onActivityResult() method to get the result, here the captured image.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With