我希望在通话后开始新的活动并使用改造并行完成7个差异请求
我应该在哪里调用startActivity()方法?
这是我错误的尝试。
new Thread(new Runnable() {
@Override
public void run() {
api.method1(args..).enqueue(new Callback<Response1>() {
@Override
public void onResponse(Call<Response1> call, Response<Response1> response) {
//do some things
}
@Override
public void onFailure(Call<Response1> call, Throwable t) {
t.printStackTrace();
}
});
..
..
..
api.method7(args..).enqueue(new Callback<Response7>() {
@Override
public void onResponse(Call<Response7> call, Response<Response7> response) {
//do some things
}
@Override
public void onFailure(Call<Response7> call, Throwable t) {
t.printStackTrace();
}
});
startActivity(new Intent(current.this,next.class));
}).start();
答案 0 :(得分:2)
使用Rxjava和Retrofit然后你可以做类似的事情(假设method1,method2等返回Observable<Response1>
,Observable<Response2>
等)
Observable.zip(api.method1, api.method2, ...)