Open xchengDroid opened 7 years ago
In RxPermissions.class
,the method requestImplementation(final String... permissions)
has a bug that will always reference Activity instance when activity recreate
PublishSubject<Permission> subject = mRxPermissionsFragment.getSubjectByPermission(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
mRxPermissionsFragment.setSubjectForPermission(permission, subject);
}
list.add(subject);
PublishSubject<Permission> subject = mRxPermissionsFragment.getSubjectByPermission(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
}
subject = PublishSubject.create();
mRxPermissionsFragment.setSubjectForPermission(permission, subject);
list.add(subject);
It will override next same permission that not reference the Activity instance and never called callback more than once when it destroyed
sorry for my bad english
@xchengDroid could you share a project where we can be able to reproduce this issue?
@epool It is very simple to reproduce this issue! you just start an activity that make request permission at onCreate method then make it change screen orientation ,it will recreate, and click allow permission, the callback will be called more than once.
@xchengDroid I think you probably missing disposing inside onDestroy
method in activity.
Example is available here: https://github.com/tbruyelle/RxPermissions/blob/master/sample/src/main/java/com/tbruyelle/rxpermissions2/sample/MainActivity.java#L83-L89
Because You aren't disposing this Observable it is created twice and that's why You have multiple callbacks.
@Override
when MainActivity's screenOrientation changed and recreated , I click allow permission and accept(Boolean aBoolean) method will be called 3 times ,can you tell me how to resolve this problem