nabinbhandari / Android-Permissions

Library for easy handling of android run-time permissions.
410 stars 84 forks source link

Runtime Exception #16

Closed ytheekshana closed 5 years ago

ytheekshana commented 5 years ago

Hi. I am using your library in my app. I got a Runtime Exception only on some devices. I cant figure out why... Here's the log

`Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=6937, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.ytheekshana.deviceinfo/com.nabinbhandari.android.permissions.PermissionsActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
   at android.app.ActivityThread.deliverResults(ActivityThread.java:4926)
   at android.app.ActivityThread.handleSendResult(ActivityThread.java:4969)
   at android.app.ActivityThread.access$1600(ActivityThread.java:222)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1850)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:158)
   at android.app.ActivityThread.main(ActivityThread.java:7230)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)`

In my fragment

        `HorizontalScrollView scrollViewCamera = rootView.findViewById(R.id.scrollViewCamera);
        cameraButtonGroup = rootView.findViewById(R.id.cameraButtonGroup);
        recyclerCamera = rootView.findViewById(R.id.recyclerCamera);
        Button btnCameraPermission = rootView.findViewById(R.id.btnCameraPermission);

        if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            btnCameraPermission.setVisibility(View.VISIBLE);
            scrollViewCamera.setVisibility(View.GONE);
            recyclerCamera.setVisibility(View.GONE);
        } else {
            btnCameraPermission.setVisibility(View.GONE);
            scrollViewCamera.setVisibility(View.VISIBLE);
            recyclerCamera.setVisibility(View.VISIBLE);
            loadCameraAll();
        }
        btnCameraPermission.setOnClickListener(view -> Permissions.check(context, Manifest.permission.CAMERA, null, new PermissionHandler() {
            @Override
            public void onGranted() {
                btnCameraPermission.setVisibility(View.GONE);
                scrollViewCamera.setVisibility(View.VISIBLE);
                recyclerCamera.setVisibility(View.VISIBLE);
                loadCameraAll();
            }

            @Override
            public void onDenied(Context context, ArrayList<String> deniedPermissions) {
            }
        }));`

Any fix for this ? Happened in 4 devices with Android 6.0. Looks like this bug is only in Marshmallow devices.

nabinbhandari commented 5 years ago

Can you provide me with the minimal code that leads to crash, or guide me how to reproduce it?

ytheekshana commented 5 years ago

Fixed it. The issue was on my side. Thanks