简体   繁体   English

未覆盖AsyncHttpClient OnSuccess或OnFailure,但已收到回调

[英]AsyncHttpClient OnSuccess or OnFailure was not overriden, but callback was received

Im trying to connect to my Android App with my MySQL database, but AsyncHttpClient is not invoking callbacks. 我试图用我的MySQL数据库连接到我的Android应用程序,但是AsyncHttpClient没有调用回调。 I have overriden all OnSucces but it always says: W/JsonHttpRH: onSuccess(int, Header[], JSONObject) was not overriden, but callback was received 我已经重写了所有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;
        }
    });

My AndroidManifest looks like: 我的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>

Where is my code failing? 我的代码在哪里失败? I used Log but nothing were logged. 我使用了Log,但未记录任何内容。 I tried an invalid URL and it doesnt care what onFailure method I call, it's never invoked. 我尝试了一个无效的URL,它并不在乎我调用的onFailure方法是什么,它从未被调用过。 The url I'm trying to download data is https://ohmysoft.pw/reservasAula/api/aulas 我要下载数据的网址https://ohmysoft.pw/reservasAula/api/aulas

You should not call super.onFailure() or super.onSuccess() . 您不应调用super.onFailure()super.onSuccess() Those warnings come from super methods when you're not overriding them. 当您不覆盖它们时,这些警告来自超级方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM