Android 未经许可读写 - Theta

Android Read and Write Without Requesting Permission - Theta

我的插件需要读写权限,我尝试了很多东西。

清单中

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

但根据其他帖子,在 v23 之后无法正常工作,所以我尝试使用 requestPermission,但我的应用程序崩溃了,在实际用例中我没有任何界面。

我正在使用 RICOH THETA Plug-in SDK

我正在尝试使用 BitmapFactory 并遇到此错误

E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/DCIM/100RICOH/R0010156.JPG (Permission denied)

如果有人知道怎么做。 谢谢。

你必须在android 6及以上使用dexter库中手动授予权限 Linkhttps://github.com/Karumi/Dexter

首先你应该检查 android 版本

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
                ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED {

           // do work

        } else {

            String[] permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                requestPermissions(permissions, 100);
            }
        }
    } else {

                      // do work
    }

别担心。 THETA 插件商店在安装时自动授予所有权限。用户在实际用例中不需要手动授予权限。您只需要在开发时手动授予权限。

official document描述

Declaration of Permissions

When installing from the RICOH THETA store, based on the protection level set in the manifest file, permission is automatically granted. During development, use an application that displays the screen such as Vysor, and grant permission from the application settings or from a plug-in dialog window.