我使用这个库loopj/android-async-http在安卓应用程序中执行网络操作。在AsyncTask的情况下,当您在asynctask运行时按下后退按钮时,您可以取消它,onBackPressed。我想知道如何在这个库loopj/android-async-http中做到这一点。
以防AsyncTask。我们确实喜欢下面
@Override
public void onBackPressed() {
mMyAsyncTask.cancel(true);
}我必须处理这个问题吗?还是环j/android-异步-http自动处理,而不需要担心这个问题?
提前谢谢。
发布于 2014-10-12 10:41:48
我在片段中是这样做的&它对我来说很好。
@Override
public void onDestroy() {
super.onDestroy();
// true specifies that even if the request is active it will be cancelled.
if (asyncHttpClient != null) asyncHttpClient.cancelRequests(getActivity(), true);
}https://stackoverflow.com/questions/25926999
复制相似问题