如何在Android中停止并恢复observable?

时间:2017-11-03 22:34:52

标签: android observable rx-android rx-java2

    Observable.create(new ObservableOnSubscribe<String>() {
        @Override
        public void subscribe(ObservableEmitter<String> e) throws Exception {
            while (!Thread.currentThread().isInterrupted()) {
                //TODO
            }

        }
    })
            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(observer);

所以我有这段代码。我想在执行onResume()方法时开始发出值,并在执行onPause()方法时停止它。我怎么能这样做?

提前致谢!

0 个答案:

没有答案