【发布时间】:2016-02-18 19:14:33
【问题描述】:
我正在尝试使用我的 MySQL 数据库连接到我的 Android 应用程序,但 AsyncHttpClient 没有调用回调。我已经覆盖了所有 OnSucces 但它总是说: W/JsonHttpRH: onSuccess(int, Header[], JSONObject) 没有被覆盖,但是收到了回调
cliente.get(LOGIN, params, new JsonHttpResponseHandler(true) {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
super.onSuccess(statusCode, headers, response);
try {
if (response.getString("nombre").equals(user))
resultado[0] = true;
} catch (JSONException e) {
resultado[0] = false;
}
}
@Override
public void onSuccess(int statusCode, Header[] headers, String responseString) {
super.onSuccess(statusCode, headers, responseString);
resultado[0] = true;
}
@Override
public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
super.onSuccess(statusCode, headers, response);
resultado[0] = true;
}
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
super.onFailure(statusCode, headers, responseString, throwable);
resultado[0] = false;
}
});
我的 AndroidManifest 看起来像:
enter code here<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.carlos.reservasaula">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".ActivityLogin"
android:label="@string/title_activity_activity_login"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我的代码哪里出错了?我使用了 Log 但没有记录任何内容。我尝试了一个无效的 URL,它不关心我调用的 onFailure 方法,它从未被调用过。我要下载数据的网址是https://ohmysoft.pw/reservasAula/api/aulas
【问题讨论】:
-
我尝试在构造函数中使用“true”参数,只是为了尝试更多,但它根本没有改变。
标签: java android android-studio android-async-http