當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncHttpClient.post方法代碼示例

本文整理匯總了Java中com.loopj.android.http.AsyncHttpClient.post方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncHttpClient.post方法的具體用法?Java AsyncHttpClient.post怎麽用?Java AsyncHttpClient.post使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.loopj.android.http.AsyncHttpClient的用法示例。


在下文中一共展示了AsyncHttpClient.post方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: executeSample

import com.loopj.android.http.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    RequestParams params = new RequestParams();
    params.setUseJsonStreamer(true);
    JSONObject body;
    if (isRequestBodyAllowed() && (body = getBodyTextAsJSON()) != null) {
        try {
            Iterator keys = body.keys();
            Log.d(LOG_TAG, "JSON data:");
            while (keys.hasNext()) {
                String key = (String) keys.next();
                Log.d(LOG_TAG, "  " + key + ": " + body.get(key));
                params.put(key, body.get(key).toString());
            }
        } catch (JSONException e) {
            Log.w(LOG_TAG, "Unable to retrieve a JSON value", e);
        }
    }
    return client.post(this, URL, headers, params,
            RequestParams.APPLICATION_JSON, responseHandler);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:JsonStreamerSample.java

示例2: executeSample

import com.loopj.android.http.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    RequestParams rParams = new RequestParams();
    rParams.put("sample_key", "Sample String");
    try {
        File sample_file = File.createTempFile("temp_", "_handled", getCacheDir());
        rParams.put("sample_file", sample_file);
    } catch (IOException e) {
        Log.e(LOG_TAG, "Cannot add sample file", e);
    }
    return client.post(this, URL, headers, rParams, "multipart/form-data", responseHandler);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:ContentTypeForHttpEntitySample.java

示例3: executeSample

import com.loopj.android.http.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    try {
        RequestParams params = new RequestParams();
        final String contentType = RequestParams.APPLICATION_OCTET_STREAM;
        params.put("fileOne", createTempFile("fileOne", 1020), contentType, "fileOne");
        params.put("fileTwo", createTempFile("fileTwo", 1030), contentType);
        params.put("fileThree", createTempFile("fileThree", 1040), contentType, "customFileThree");
        params.put("fileFour", createTempFile("fileFour", 1050), contentType);
        params.put("fileFive", createTempFile("fileFive", 1060), contentType, "testingFileFive");
        params.setHttpEntityIsRepeatable(true);
        params.setUseJsonStreamer(false);
        return client.post(this, URL, params, responseHandler);
    } catch (FileNotFoundException fnfException) {
        Log.e(LOG_TAG, "executeSample failed with FileNotFoundException", fnfException);
    }
    return null;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:FilesSample.java

示例4: addBehaviors

import com.loopj.android.http.AsyncHttpClient; //導入方法依賴的package包/類
public static void addBehaviors(String json, TextHttpResponseHandler handler) {
    RequestParams params = new RequestParams("json", json);
    AsyncHttpClient client = new AsyncHttpClient();
    client.addHeader("passcode", BuildConfig.VIOLET_PASSCODE);
    client.post(URL, params, handler);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:7,代碼來源:API.java

示例5: executeSample

import com.loopj.android.http.AsyncHttpClient; //導入方法依賴的package包/類
@Override
public RequestHandle executeSample(AsyncHttpClient client, String URL, Header[] headers, HttpEntity entity, ResponseHandlerInterface responseHandler) {
    return client.post(this, URL, headers, entity, null, responseHandler);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:PrePostProcessingSample.java


注:本文中的com.loopj.android.http.AsyncHttpClient.post方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。