8000 GitHub - nekocode/RxActivityResult: This is a library that can help you to receive results from startActivityForResult() as an Observable.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

This is a library that can help you to receive results from startActivityForResult() as an Observable.

Notifications You must be signed in to change notification settings

nekocode/RxActivityResult

Repository files navigation

RxActivityResult

Apache 2.0 License Release

This is a library that can help you to receive results from startActivityForResult() as an Observable. You can use it in Activity or Fragment. It actullay call the startActivityForResult() in a Headless-Fragment that attaching to your Activity(/Fragment). And publish the activity results in the Headless-Fragment's onActivityResult().

Supports only RxJava 2 now.

Usage

Example:

RxActivityResult.startActivityForResult(this, intent, REQUEST_CODE)
        .subscribe(new Consumer<ActivityResult>() {
            @Override
            public void accept(@NonNull ActivityResult result) throws Exception {
                if (result.isOk()) {
                    final Intent data = result.getData();
                    // DO SOME THING
                }
            }
        });

See the sample for more detail.

Using with gradle

  • Add the JitPack repository to your build.gradle repositories:
repositories {
    // ...
    maven { url "https://jitpack.io" }
}
  • Add the core dependency:
dependencies {
    compile 'com.github.nekocode.rxactivityresult:rxactivityresult:{lastest-version}'
}
  • (Optional) Add the below library if you need to support api 9 and later. Besides, if you already add support-v4 dependency, I will also suggest you to use this compact library, and then use the RxActivityResultCompact instead of the RxActivityResult.
dependencies {
    compile 'com.github.nekocode.rxactivityresult:rxactivityresult-compact:{lastest-version}'
}

About

This is a library that can help you to receive results from startActivityForResult() as an Observable.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0