【问题标题】:Unable to capture image using camera intent in samsung note 3无法在三星注释 3 中使用相机意图捕获图像
【发布时间】:2017-07-13 13:21:46
【问题描述】:

这可能是一个老问题,但我找不到任何解决方案。所以再问一遍

我正在尝试捕获图像并将其存储在内部存储中,并在我的应用程序中使用后将其删除。它在除三星 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) {
    }
}

我在这里缺少什么。谁能帮帮我

【问题讨论】:

  • 试试this 链接上的代码。效果很好!

标签: android android-camera samsung-mobile samsung-galaxy


【解决方案1】:

在 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-09
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多