Android screenshot detector with ContentObserver and Rx.
Note that this library only work as best effort, it won't (and can't I think) cover corner cases. Good luck with it :)
Add to gradle dependency of your module build.gradle:
repositories {
maven {
url "http://dl.bintray.com/piasy/maven"
}
}
dependencies {
compile 'com.github.piasy:rxscreenshotdetector:1.1.0'
}
Use in code:
RxScreenshotDetector.start(getApplicationContext())
//.compose(bindToLifecycle()) // todo wait for RxLifeCycle 2.x
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<String>() {
@Override
public void accept(String path) throws Exception {
mTextView.setText(mTextView.getText() + "\nScreenshot: " + path);
}
});
See full example for more details.
- Thanks for RxPermissions, for request permission in reactive way.