-1

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.

coco
  • 31
  • 6

3 Answers3

0

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

  • I would not suggest to add an external library, only for handling permissions. You'll depend on the library, instead of learning the proper way. – barotia Sep 03 '19 at 11:24
  • I tried but the application crashed, I think this library use pop-up request request asking the user to choose the permission, if so it is not the library I need. – coco Sep 03 '19 at 14:03
0

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
    }
Mehrdad
  • 1,477
  • 15
  • 17
  • I tried and it goes to the level of String[] permissions = .... and when it's run `requestPermissions()` the app crash – coco Sep 03 '19 at 12:09
  • send me a screenshot from logcat (blue lines) – Mehrdad Sep 03 '19 at 12:51
  • it's impossible :))) when the app crashed, the error is shown in logcat by blue color – Mehrdad Sep 04 '19 at 05:40
  • your blue line is `Debug` mod? can you try dl SDK and put your code in and run in any android smartphone, normally has the same behaviour – coco Sep 04 '19 at 08:23
0

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.

Hideki SHIRO
  • 108
  • 1
  • 4