Android从按钮打开相机 [英] Android open camera from button
问题描述
我希望这不是一个重复的问题,但是我正在制作一个我想要一个按钮来打开相机应用程序的应用程序(分别是默认的Android相机).我该怎么做呢?我知道有一个功能:
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)
我需要使用那个吗?以及如何从xml文件中调用按钮?
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?
推荐答案
要调用相机,您可以使用:
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.
您需要在AndroidManifest.xml中设置摄像机的权限:
And you need to set the permission for the camera in your AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA"> </uses-permission>
这篇关于Android从按钮打开相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!