AsyncHttpClient OnSuccess未执行

时间:2015-06-03 09:41:00

标签: android apache android-studio

这是我在控制台中获得的内容:

onSuccess(int, Header[], JSONObject) was not overriden, but callback was received

我已经过验证,文件已上传到服务器。

这是我的代码,应用程序没有抱怨:

public void uploadImage() {
        //Create a new RequestParams that will send paremeters with our AsyncHttpClient request.
        RequestParams data = new RequestParams();

        //Adding our image to the parameters.
        File image = new File(imgPath);
        try {
        data.put("image", image);
    } catch(FileNotFoundException e) {}
    //Create a new AsyncHttpClient request.
    //here we're sending a POST request, the first parameter is the request URL
    // then our RequestParams, in our case data and then a Json response handler.
    AsyncHttpClient client = new AsyncHttpClient();
    client.post(FILE_UPLOAD_URL, data, new JsonHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header headers[], JSONArray success) {
            try {
                JSONObject data = success.getJSONObject(0);
                String m = data.getString("message");
                Toast.makeText(UploadPhotoTest.this, m, Toast.LENGTH_LONG).show();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
}

如果相关的话,这就是我导入的内容:

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

我的问题是,OnSuccess中的任何内容都永远不会被执行..我在OnSuccess中输入一个日志并捕获并且没有任何内容被打印出来。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

03-04 17:04:57.399 5076-5543/? W/System.err: java.lang.SecurityException: Permission Denial: opening provider com.google.android.gms.games.chimera.GamesContentProviderProxy from ProcessRecord{42f038e8 9143:com.mygame.test/u0a132} (pid=9143, uid=10132) that is not exported from uid 10013 03-04 17:04:57.425 9143-9164/? W/ImageView: Unable to open content: content://com.google.android.gms.games.background/images/85348a8/343 java.lang.SecurityException: Permission Denial: opening provider com.google.android.gms.games.chimera.GamesContentProviderProxy from ProcessRecord{42f038e8 9143:com.mygame.test/u0a132} (pid=9143, uid=10132) that is not exported from uid 10013 at android.os.Parcel.readException(Parcel.java:1472) at android.os.Parcel.readException(Parcel.java:1426)

这对我有用。