Smo*_*_js 3 javascript mobile camera android react-native
在你说这是重复之前让我解释一下.我知道如何在React Native中使用Camera,但在上个月的Android(Java)中,我以简单的方式管理了设备相机,我甚至不必创建一个新的View来使用它.我刚刚做了这样的事情:
Uri mOutputFileUri;
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mOutputFileUri); // URI of the file where pic will be stored
startActivityForResult(intent, TAKE_PICTURE_FROM_CAMERA);
Run Code Online (Sandbox Code Playgroud)
基本上这会自动打开相机,当按下"拍摄照片按钮"时,调用onActivityForResult()方法,获取要管理的图像数据.
所以,我怀疑是,有一种方法可以在React Native中做到这一点吗?我的意思是,调用一种自动打开相机并返回数据的方法?
非常感谢.
小智 12
最简单的方法是使用ImagePicker库https://github.com/react-community/react-native-image-picker
这允许您打开本机摄像头并使用照片中的数据提供回调.
ImagePicker.launchCamera(options, (response) => {
// Response data
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6913 次 |
| 最近记录: |