I am learning restful services in http://www.raywenderlich.com/78578/android-tutorial-for-beginners-part-3
while coming across
AsyncHttpClient client = new AsyncHttpClient();
client.get(QUERY_URL + urlString,
new JsonHttpResponseHandler() {
@Override
public void onSuccess(JSONObject jsonObject) {
// Display a "Toast" message
// to announce your success
Toast.makeText(getApplicationContext(), "Success!", Toast.LENGTH_LONG).show();
// 8. For now, just log results
Log.d("omg android", jsonObject.toString());
}
@Override
public void onFailure(int statusCode, Throwable throwable, JSONObject error) {
// Display a "Toast" message
// to announce the failure
Toast.makeText(getApplicationContext(), "Error: " + statusCode + " " + throwable.getMessage(), Toast.LENGTH_LONG).show();
// Log error message
// to help solve any problems
Log.e("omg android", statusCode + " " + throwable.getMessage());
}
});
My gradle sync task was successful.But I couldn't figure out that why onSuccess method is enlightened as (Method does not override super class)
Even I have changed the onSuccess() parameters to
public void onSuccess(int statusCode, org.apache.http.Header[] headers, JSONObject jsonObject)
and also I have followed all the solutions provided in the following links
method does not override or implement a method from a supertype - for Override
Even I have tried using interfaces also.And I am using async http 1.4.9 So I have changed the gradle scripts as
dependencies {
...
// there may or may not be a support library above these
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.squareup.picasso:picasso:2.5.2'
}
I have tried all the solutions available in stackoverflow and github.But still I couldn't clear that error and it is showing me onSuccess() and onFailure() methods doesn't override the superclass
Check you imports
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import org.json.JSONObject;
**import cz.msebera.android.httpclient.Header;**
and try this
client.get("sdsd", new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
super.onSuccess(statusCode, headers, response);
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
super.onFailure(statusCode, headers, throwable, errorResponse);
}
});
You are using the wrong Header and overriding nonexistent methods. I think may be those were available on an old release.