我试图用我的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
答案 0 :(得分:0)
您不应该致电super.onFailure()
或super.onSuccess()
。当你没有覆盖它们时,这些警告来自超级方法。