android AsyncHttpClient问题 50
publicList<StarUser>getAllStar(){AsyncHttpClientclient=newAsyncHttpClient();userList=...
public List<StarUser> getAllStar() {
AsyncHttpClient client = new AsyncHttpClient();
userList = new ArrayList<StarUser>();
String tim= TransverterUtil.getTime();
String userId = GlobalVariables.LOCALUSER.toString();
String auth = MD5Utils.GetMD5CodeforMehtod("UserID="
+ userId + "&t=" + tim);
HttpUtil.getClient().get(
GlobalVariables.serverAddress + "/GETUSERINFO_BYUSERID.ashx?UserID="
+ userId + "&auth=" + auth + "&t=" + tim, new TextHttpResponseHandler() {
@Override
public void onFailure(int i, Header[] headers, String s, Throwable throwable) {
Toast.makeText(context,
"成功", 0).show();
}
@Override
public void onSuccess(int i, Header[] headers, String s) {
Toast.makeText(context,
"成功", 0).show();
}
}
);
return userList;
}
确定执行了get方法,但是onFailure和onSuccess都执行不了,请问这是为什么
是在Fragment中调用的 展开
AsyncHttpClient client = new AsyncHttpClient();
userList = new ArrayList<StarUser>();
String tim= TransverterUtil.getTime();
String userId = GlobalVariables.LOCALUSER.toString();
String auth = MD5Utils.GetMD5CodeforMehtod("UserID="
+ userId + "&t=" + tim);
HttpUtil.getClient().get(
GlobalVariables.serverAddress + "/GETUSERINFO_BYUSERID.ashx?UserID="
+ userId + "&auth=" + auth + "&t=" + tim, new TextHttpResponseHandler() {
@Override
public void onFailure(int i, Header[] headers, String s, Throwable throwable) {
Toast.makeText(context,
"成功", 0).show();
}
@Override
public void onSuccess(int i, Header[] headers, String s) {
Toast.makeText(context,
"成功", 0).show();
}
}
);
return userList;
}
确定执行了get方法,但是onFailure和onSuccess都执行不了,请问这是为什么
是在Fragment中调用的 展开
2个回答
展开全部
写错了吧,一个是失败抛出异常,一个是成功,你检查下
更多追问追答
追问
真的没有写错的。我在想是不是因为放到了Fragment里
追答
HttpUtil.getClient().get
(
GlobalVariables.serverAddress + "/GETUSERINFO_BYUSERID.ashx?UserID="+ userId + "&auth=" + auth + "&t=" + tim, new TextHttpResponseHandler()
{
system.out.println("输出1");
@Override
public void onFailure(int i, Header[] headers, String s, Throwable throwable)
{
Toast.makeText(context,"失败", 0).show();
}
@Override
public void onSuccess(int i, Header[] headers, String s)
{
Toast.makeText(context,"成功", 0).show();
}
}
system.out.println("输出2");
);
你先这样看看,输出一下,看看这个方法执行的怎么样,再做下一步调试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询