diff --git a/dexter/src/main/java/com/karumi/dexter/DexterInstance.java b/dexter/src/main/java/com/karumi/dexter/DexterInstance.java index a93feb42..492b3919 100644 --- a/dexter/src/main/java/com/karumi/dexter/DexterInstance.java +++ b/dexter/src/main/java/com/karumi/dexter/DexterInstance.java @@ -125,6 +125,7 @@ void onActivityReady(Activity activity) { */ void onActivityDestroyed() { isRequestingPermission.set(false); + listener = EMPTY_LISTENER; } /** @@ -322,6 +323,7 @@ private void checkMultiplePermissions(final MultiplePermissionsListener listener } isRequestingPermission.set(false); listener.onPermissionsChecked(report); + DexterInstance.this.listener = EMPTY_LISTENER; } }); } else { diff --git a/dexter/src/test/java/com/karumi/dexter/DexterInstanceTest.java b/dexter/src/test/java/com/karumi/dexter/DexterInstanceTest.java index b8e16021..53787f90 100644 --- a/dexter/src/test/java/com/karumi/dexter/DexterInstanceTest.java +++ b/dexter/src/test/java/com/karumi/dexter/DexterInstanceTest.java @@ -132,6 +132,7 @@ public void onCheckPermissionMoreThanOnceThenThrowException() { } @Test public void onPermissionFailedByRuntimeExceptionThenNotifiesListener() { + givenPermissionIsChecked(ANY_PERMISSION, PackageManager.PERMISSION_DENIED); givenARuntimeExceptionIsThrownWhenPermissionIsChecked(ANY_PERMISSION); givenShouldShowRationaleForPermission(ANY_PERMISSION); diff --git a/sample/build.gradle b/sample/build.gradle index 7c192138..9717432d 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -34,6 +34,7 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:design:27.1.1' implementation 'com.jakewharton:butterknife:8.6.0' + implementation 'com.squareup.leakcanary:leakcanary-android:1.5.4' annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' implementation project(':dexter') androidTestImplementation 'com.android.support.test:runner:0.5' diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 1b9fbd8a..f39b4725 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -23,6 +23,7 @@