Android Read and Write Without Requesting Permission - Theta

249 Views Asked by At

i need permission read and write for my plugin, i try a lot of things.

In manifest

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

but not working after v23 according to others posts, so i try with requestPermission but my app crash and in real use case i don't have any interface.

I'm using RICOH THETA Plug-in SDK

I'm trying to use BitmapFactory and got this error

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

If someone has any idea how to do it. Thanks.

3

There are 3 best solutions below

0
On BEST ANSWER

Don't worry. THETA Plug-in store grants all permission automatically on instal time. Users do not need to grant permissions manually in actual use case. You need to grant permissions manually only for development time.

The official document describes that

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.

4
On

in first you should check android version

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
    }
2
On

You have to give permission manually in android 6 and above use dexter library Link https://github.com/Karumi/Dexter