IntentService调用同步请求错误

时间:2017-12-19 08:22:48

标签: android retrofit2

我运行IntentService。此IntentService在后台运行。 我有Retrofit电话。我做同步模式。

Call<Object> call = apiService.getItem(id);

try {
    Response<Object> response = call.execute();
    if (response.isSuccessful()) {
        return response.body();
    }
} catch (IOException e) {
    //...
}

有时我得到android.os.NetworkOnMainThreadException,但为什么? 它不在后台线程上运行?

请给我一些想法。如果我需要在异步模式下实现它,真的很难。 谢谢!

更新:

@Override
    protected void onHandleIntent(@Nullable Intent intent) {
          startTransaction();
    }

0 个答案:

没有答案
相关问题