这是使用rxjava
(and retrofit
) 的典型网络调用。可以JobScheduler
用这个代替吗?如果是,如何?最重要的是,是否推荐?
Observable<GenericResponse> observable = someInterface.someMethod();
observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<GenericResponse>() {
@Override
public void onCompleted() {
Log.d(TAG, "Success");
}
@Override
public void onError(Throwable e) {
Log.e(TAG, "Error: ", e);
}
@Override
public void onNext(GenericResponse genericResponse) {
Log.d(TAG, "onNext");
}
});