1

这可能是一个老问题,但我找不到任何解决方案。于是又问了

我正在尝试捕获图像并将其存储在内部存储中,并在我的应用程序中使用后将其删除。它在除三星 Note 3 之外的所有设备上都运行良好。

private void captureImage() {
        try {
            if(photoPath!=null) {
                new File(photoPath).delete();
                photoPath = null;
            }
            //SET THE IMAGE NAME AND IMAGE PATH FOR THE CURRENT IMAGE 
            final Random random = new Random();
            photoPath = getPath(this)+"/img" + String.valueOf(random.nextInt()) + ".jpg";
            final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            final File imageStorage = new File(photoPath);
            if (imageStorage != null) {
                //to capture full image use URI otherwise use filepath
                 Uri photoURI = FileProvider.getUriForFile(this, "<<my path>>.fileprovider", imageStorage);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                startActivityForResult(intent, Constants.ACTION_CAMERA_REQUEST);
            }
    }
    catch (Throwable e) {
    }
}

有什么我在这里想念的吗。请任何人都可以帮助我

4

1 回答 1

-2

在 Manifeast.xml 中

<uses-permission android:name="android.permission.CAMERA" />

为了使用相机是强制性的(我没有通过 Intent 使用相机,我有一个自定义相机应用程序)

<uses-feature android:name="android.hardware.camera" 
android:required="false"/>
<uses-feature android:name="android.hardware.camera.flash" 
android:required="false" />

android:required="false" 表示 Google Play 不会阻止将应用程序安装到不包含这些摄像头功能的设备上 - 因此拥有没有摄像头和摄像头闪光灯的设备的用户将能够从市场上安装该应用程序。

http://developer.android.com/reference/android/hardware/Camera.html

于 2017-07-13T05:21:46.257 回答