googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.87k stars 1.46k forks source link

In Fragment easypermissions not working fine getting the following issue #223

Closed imramsuthakar closed 6 years ago

imramsuthakar commented 6 years ago

Basic Information

Device type: Vivo V9 OS version: 8.0 EasyPermissions version: 1.2.0

I Have tried to add the Call permission in Fragment it will getting crashed the initial time after that it will working fine, the same code in activity working always fine. I have posted my log in below

What happened? What did you expect to happen?

Caused by: java.lang.RuntimeException: Cannot execute method callTask because it is non-void method and/or has input parameters.

 07-07 16:55:07.598 21262-21262/com.geordana.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.geordana.app, PID: 21262
java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=65658, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.geordana.app/com.geordana.app.Activity.appoinments.AppoinmentsActivity}: java.lang.RuntimeException: Cannot execute method callTask because it is non-void method and/or has input parameters.
    at android.app.ActivityThread.deliverResults(ActivityThread.java:4371)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4415)
    at android.app.ActivityThread.-wrap19(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:192)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818)
 Caused by: java.lang.RuntimeException: Cannot execute method callTask because it is non-void method and/or has input parameters.
    at pub.devrel.easypermissions.EasyPermissions.runAnnotatedMethods(EasyPermissions.java:421)
    at pub.devrel.easypermissions.EasyPermissions.onRequestPermissionsResult(EasyPermissions.java:285)
    at com.geordana.app.Fragments.upcoming.UpcomingTripFragment.onRequestPermissionsResult(UpcomingTripFragment.java:198)
    at android.support.v4.app.FragmentActivity.onRequestPermissionsResult(FragmentActivity.java:804)
    at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7537)
    at android.app.Activity.dispatchActivityResult(Activity.java:7388)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:4367)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4415) 
    at android.app.ActivityThread.-wrap19(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:192) 
    at android.app.ActivityThread.main(ActivityThread.java:6669) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818) 

07-07 16:55:07.600 21262-21262/com.geordana.app E/UncaughtException: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=65658, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.geordana.app/com.geordana.app.Activity.appoinments.AppoinmentsActivity}: java.lang.RuntimeException: Cannot execute method callTask because it is non-void method and/or has input parameters. at android.app.ActivityThread.deliverResults(ActivityThread.java:4371) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4415) at android.app.ActivityThread.-wrap19(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1699) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:192) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:818) Caused by: java.lang.RuntimeException: Cannot execute method callTask because it is non-void method and/or has input parameters. at pub.devrel.easypermissions.EasyPermissions.runAnnotatedMethods(EasyPermissions.java:421) at pub.devrel.easypermissions.EasyPermissions.onRequestPermissionsResult(EasyPermissions.java:285) at com.geordana.app.Fragments.upcoming.UpcomingTripFragment.onRequestPermissionsResult(UpcomingTripFragment.java:198) at android.support.v4.app.FragmentActivity.onRequestPermissionsResult(FragmentActivity.java:804) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7537) at android.app.Activity.dispatchActivityResult(Activity.java:7388) at android.app.ActivityThread.deliverResults(ActivityThread.java:4367)

// TODO(you): show the code that produces the problem,
//            and any relevant logs.

@AfterPermissionGranted(Constants.RC_CALL_PHONE) private void callTask(String doctorNumber) { if (EasyPermissions.hasPermissions(getActivity(), CALL_PHONE)) { // Have permission, do the thing! Toast.makeText(getActivity(), "TODO: SMS things", Toast.LENGTH_LONG).show();

        makeCall(doctorNumber);

    } else {
        // Request one permission
        EasyPermissions.requestPermissions(
                this,"Please give the CALL PERMISSION!",
                Constants.RC_CALL_PHONE,
                CALL_PHONE);
    }
}

@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    // Forward results to EasyPermissions
    EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}