Sae*_*ari 5 android rx-java rx-android retrofit2
我正在尝试使用RxJava这样的Retrofit阻止调用:
remote = Single.fromCallable(new Callable<List>() {
@Override
public List call() {
try {
Response<ApiResponse> execute = makeRequest().execute();
} catch (Exception e) {
e.printStackTrace();
return new ArrayList();
}
}
...
Run Code Online (Sandbox Code Playgroud)
我正在订阅:
remote
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
Run Code Online (Sandbox Code Playgroud)
但是调用执行会引发NetworkOnMainThreadException。
我在用
compile 'com.squareup.retrofit2:retrofit:2.1.0'
Run Code Online (Sandbox Code Playgroud)
并且在此问题中,据说该错误已修复,但我仍然可以得到。
我该怎么解决?
| 归档时间: |
|
| 查看次数: |
100 次 |
| 最近记录: |