gpt4 book ai didi

android - new AsyncHttpResponseHandler() 总是会失败

转载 作者:行者123 更新时间:2023-12-05 00:21:51 26 4
gpt4 key购买 nike

AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.put("username", username);
params.put("password", password);
client.post("192.168.12.4/administration/include/login.php", params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
System.out.println("onSuccess");
Toast.makeText(getApplicationContext(), "MySQL DB has been informed about Sync activity", Toast.LENGTH_LONG).show();
}

@Override
public void onFailure(int statusCode, Throwable error, String content) {
System.out.println("onFailure");
Toast.makeText(getApplicationContext(), "Error Occured", Toast.LENGTH_LONG).show();
}
});

如果我有上面的代码可能会导致它转到 public void onFailure(int statusCode, Throwable error, String content) {}而不是 public void onSuccess(String response) {}
在哪里 192.168.12.4是运行 localhost 的计算机的 IP,以及包含 login.php 的项目所在的计算机的 IP。位于

最佳答案

如果这是用于模拟器测试的开发人员计算机(运行模拟器的 PC),则必须将 URL 值更改为

http://10.0.2.2/administration/include/login.php

并且不要忘记将其添加到您的 list 文件中
<uses-permission android:name="android.permission.INTERNET" />

关于android - new AsyncHttpResponseHandler() 总是会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39892314/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com