Comments (8)
Well, I also use the library to request multiple times a critical permission, but I don't have the problem you describe. That said I'm not using those damned fragments.
Rather than removing the onDestroy
content, could you try to wipe the subject list at the end of RxPermissions.onDestroy()
:
void onDestroy() {
log("onDestroy");
// Invoke onCompleted on all registered subjects.
// This should un-subscribe the observers.
for (Subject subject : mSubjects.values()) {
subject.onCompleted();
}
+ mSubjects.clear();
}
Tell me if it fixes your issue.
from rxpermissions.
I tried your fix, but it didn’t work.
D/MainFragment: [@Observable :: @InClass -> MainFragment :: @Method -> getPermissionsObservable()]
D/MainFragment: [@Observable#getPermissionsObservable -> onSubscribe()]
D/MainFragment: [@Observable#getPermissionsObservable -> onNext() -> false]
D/MainFragment: [@Observable#getPermissionsObservable -> @SubscribeOn -> main :: @ObserveOn -> main]
D/MainFragment: [@Observable#getPermissionsObservable -> onUnsubscribe()]
D/MainFragment: [@Observable :: @InClass -> MainFragment :: @Method -> getPermissionsObservable()]
D/MainFragment: [@Observable#getPermissionsObservable -> onSubscribe()]
D/MainFragment: [@Observable#getPermissionsObservable -> onCompleted()]
D/MainFragment: [@Observable#getPermissionsObservable -> onTerminate()]
D/MainFragment: [@Observable#getPermissionsObservable -> @Emitted -> 0 elements :: @Time -> 223 ms]
D/MainFragment: [@Observable#getPermissionsObservable -> :: @ObserveOn -> main]
D/MainFragment: [@Observable#getPermissionsObservable -> onUnsubscribe()]
The problem with this is that still onDestroy()
gets called before onRequestPermissionResult()
:
D/RxPermissions: Requesting permissions android.permission.ACCESS_FINE_LOCATION
D/RxPermissions: startShadowActivity android.permission.ACCESS_FINE_LOCATION
D/RxPermissions: onRequestPermissionsResult android.permission.ACCESS_FINE_LOCATION
D/RxPermissions: Requesting permissions android.permission.ACCESS_FINE_LOCATION
D/RxPermissions: startShadowActivity android.permission.ACCESS_FINE_LOCATION
D/RxPermissions: onDestroy
D/RxPermissions: onRequestPermissionsResult android.permission.ACCESS_FINE_LOCATION
In this case, the subject is not available anymore in onRequestPermissionResult()
, therefore throwing an exception:
java.lang.IllegalStateException: RxPermissions.onRequestPermissionsResult invoked but didn't find the corresponding permission request.
from rxpermissions.
Oh I think I get it this time. So as you explained there's no reason why an activity started with FLAG_ACTIVITY_NEW_TASK
propagate a onDestroy
event to a singleton like the RxPermissions
class.
I think we can safely remove the ShadowActivity.onDestroy
method.
Could you check if it's OK for you and then open a PR ? I will try to release it quickly.
from rxpermissions.
Was solved by #33.
from rxpermissions.
Sorry I'm going to reverse that change because it breaks configuration change handling.
When you request a permission, you see the permission dialog, if before answer you rotate your phone, your app is restarted and the permission dialog pops again automatically (it's not because of RxPermissions). If you answer at this time, the rx chaining should be invoked properly, but not any more since that change.
from rxpermissions.
In onDestroy()
you call onCompleted()
on all subjects for unsubscribing. However, in my opinion, users should unsubscribe their Subscriptions anyway, when their Activity gets destroyed (e.g. with a CompositeSubscription
).
Wouldn’t it be better to have a separate list, which contains all subjects that did not receive a result from permission requests? I created pull request #37 for implementing this. This way, configuration changes are handled correctly, while also fixing this issue.
from rxpermissions.
is the permission dialog automatically generated when you
rxPermissions.request(Manifest.permission.RECORD_AUDIO).subscribe(new Action1() {
@OverRide
public void call(Boolean aBoolean) {
Log.d(getClass().getSimpleName(), "inside call"); } });
or you need to create the permission dialog view by yourself?
P.S. my environment:
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.3@aar'
compile 'io.reactivex:rxjava:1.2.2'
from rxpermissions.
I get This issues while using this code in 4.4 Kitkat
RxPermissions rxPermissions = new RxPermissions(SplashActivity.this); rxPermissions.setLogging(true);
E: FATAL EXCEPTION: main
Process: com.package.test, PID: 8860
java.lang.VerifyError
Are there any solutions for this ????
from rxpermissions.
Related Issues (20)
- How does it work with Android 11? HOT 1
- bug: request permission twice, in one subscribe receive callback twice
- 点击dialog外侧,dialog也会取消,且shouldShowRequestPermissionRationale=flase HOT 3
- Migrate to Maven Central
- Typo is Readme File HOT 3
- Bug:Can not perform this action after onSaveInstanceState
- Gradle import failed HOT 8
- Need to Migrate JCenter to mavenCentral HOT 5
- Cannot access class 'io.reactivex.rxjava3.core.Observable'. Check your module classpath for missing or conflicting dependencies HOT 2
- Bug: requestEach callback do not contain each permission result HOT 3
- Memory Leak
- FragmentTransition Bug
- Crash with new navigation library HOT 3
- Removing Jetifier
- android 11 中 获取应用列表时一个神奇现象
- Bug can not import packagename library HOT 2
- compileSdk 33,pixel 手机android 13,请求权限失败 HOT 7
- 没有subscribe方法 HOT 1
- There is no method
- 楼主是不是不维护了啊,Android13更新,授权相关的要适配了 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxpermissions.