Giter Site home page Giter Site logo

Comments (8)

tbruyelle avatar tbruyelle commented on May 7, 2024

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.

patloew avatar patloew commented on May 7, 2024

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.

tbruyelle avatar tbruyelle commented on May 7, 2024

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.

patloew avatar patloew commented on May 7, 2024

Was solved by #33.

from rxpermissions.

tbruyelle avatar tbruyelle commented on May 7, 2024

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.

patloew avatar patloew commented on May 7, 2024

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.

hellohelloye avatar hellohelloye commented on May 7, 2024

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.

Mukeshkannan-Nplus avatar Mukeshkannan-Nplus commented on May 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.