Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Crash when request permission #78

Closed
kenilt opened this issue Jul 18, 2016 · 3 comments
Closed

Crash when request permission #78

kenilt opened this issue Jul 18, 2016 · 3 comments

Comments

@kenilt
Copy link

kenilt commented Jul 18, 2016

I have got crash error when I trying to request permission. Which below:

Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=42, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.feelsfashionltd.feels.debug/com.karumi.dexter.DexterActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.view.ViewGroup.getContext()' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:3988) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3301) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3359)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2549)  at android.app.ActivityThread.access$900(ActivityThread.java:150)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:168)  at android.app.ActivityThread.main(ActivityThread.java:5845)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.view.ViewGroup.getContext()' on a null object reference at android.support.design.widget.Snackbar.<init>(Snackbar.java:180) at android.support.design.widget.Snackbar.make(Snackbar.java:209) at com.karumi.dexter.listener.multi.SnackbarOnAnyDeniedMultiplePermissionsListener.showSnackbar(SnackbarOnAnyDeniedMultiplePermissionsListener.java:63) at com.karumi.dexter.listener.multi.SnackbarOnAnyDeniedMultiplePermissionsListener.onPermissionsChecked(SnackbarOnAnyDeniedMultiplePermissionsListener.java:58) at com.karumi.dexter.listener.multi.CompositeMultiplePermissionsListener.onPermissionsChecked(CompositeMultiplePermissionsListener.java:54) at com.karumi.dexter.MultiplePermissionListenerThreadDecorator$1.run(MultiplePermissionListenerThreadDecorator.java:45) at com.karumi.dexter.MainThread.execute(MainThread.java:32) at com.karumi.dexter.MultiplePermissionListenerThreadDecorator.onPermissionsChecked(MultiplePermissionListenerThreadDecorator.java:43) at com.karumi.dexter.DexterInstance.onPermissionsChecked(DexterInstance.java:264) at com.karumi.dexter.DexterInstance.updatePermissionsAsDenied(DexterInstance.java:247) at com.karumi.dexter.DexterInstance.onPermissionRequestDenied(DexterInstance.java:148) at com.karumi.dexter.Dexter.onPermissionsRequested(Dexter.java:176) at com.karumi.dexter.DexterActivity.onRequestPermissionsResult(DexterActivity.java:54) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6564) at android.app.Activity.dispatchActivityResult(Activity.java:6443) at android.app.ActivityThread.deliverResults(ActivityThread.java:3984) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3301)  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3359)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2549)  at android.app.ActivityThread.access$900(ActivityThread.java:150)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:168)  at android.app.ActivityThread.main(ActivityThread.java:5845)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 

Can you check this error and improve it?

Steps to reproduce

First I request Storage permission -> choose allow
Then I request Camera, Record Audio and Storage permission -> Deny all -> Crash

Version of the library

2.2.2

@Serchinastico
Copy link
Contributor

Hi @kenilt

Just a guess but I'm seeing you are using the utility SnackbarOnAnyDeniedMultiplePermissionsListener class. Have you initialized its rootView with a null value? To correctly show the snackbar you need to specify what will be its parent view to successfully attach itself to it.

You have an example of how to use this class in the provided sample project included in this repository, SampleActivity.java:148

Let us know if the issue persists.
Thanks for reporting!

@kenilt
Copy link
Author

kenilt commented Jul 18, 2016

@Serchinastico You are right. I have initialized SnackbarOnAnyDeniedMultiplePermissionsListener with a ViewGroup that have not attached to its parent successfully. I have solved it by using

view.post(new Runnable() {
        @Override
        public void run() {
            // init SnackbarOnAnyDeniedMultiplePermissionsListener here
        }
    });

Thank you!

@kenilt kenilt closed this as completed Jul 18, 2016
@riyatsa
Copy link

riyatsa commented Jun 19, 2020

Attempt to invoke interface method 'void com.karumi.dexter.listener.multi.MultiplePermissionsListener.onPermissionsChecked(com.karumi.dexter.MultiplePermissionsReport)' on a null object reference

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants