当前位置: 首页>>代码示例>>Java>>正文


Java SyncHttpClient类代码示例

本文整理汇总了Java中com.loopj.android.http.SyncHttpClient的典型用法代码示例。如果您正苦于以下问题:Java SyncHttpClient类的具体用法?Java SyncHttpClient怎么用?Java SyncHttpClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SyncHttpClient类属于com.loopj.android.http包,在下文中一共展示了SyncHttpClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeSample

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
@Override
public RequestHandle executeSample(final AsyncHttpClient client, final String URL, final Header[] headers, HttpEntity entity, final ResponseHandlerInterface responseHandler) {
    if (client instanceof SyncHttpClient) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                Log.d(LOG_TAG, "Before Request");
                client.get(SynchronousClientSample.this, URL, headers, null, responseHandler);
                Log.d(LOG_TAG, "After Request");
            }
        }).start();
    } else {
        Log.e(LOG_TAG, "Error, not using SyncHttpClient");
    }
    /**
     * SyncHttpClient does not return RequestHandle,
     * it executes each request directly,
     * therefore those requests are not in cancelable threads
     * */
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:SynchronousClientSample.java

示例2: getUnsafeSyncHttpClient

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
@NonNull
private SyncHttpClient getUnsafeSyncHttpClient() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, KeyManagementException, UnrecoverableKeyException {
    // We initialize a default Keystore
    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
    // We load the KeyStore
    trustStore.load(null, null);
    // We initialize a new SSLSocketFactory
    MySSLSocketFactory socketFactory = new MySSLSocketFactory(trustStore);
    // We set that all host names are allowed in the socket factory
    socketFactory.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    // We initialize the Async Client
    SyncHttpClient client = new SyncHttpClient();
    // We set the timeout to 30 seconds
    client.setTimeout(TIMEOUT);
    // We set the SSL Factory
    client.setSSLSocketFactory(socketFactory);
    client.setEnableRedirects(true);
    client.setUserAgent("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
    return client;
}
 
开发者ID:hatak30,项目名称:Benefit_mvvm,代码行数:21,代码来源:Repository.java

示例3: uploadFiles

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
/**
 * Upload files with {@link com.loopj.android.http.SyncHttpClient}
 *
 * @param url
 * @param paramsList
 * @param fileParams
 * @param files
 * @param responseHandler
 */
public static void uploadFiles(String url, List<NameValuePair> paramsList, String fileParams, List<File> files, AsyncHttpResponseHandler responseHandler) throws Exception {
    SyncHttpClient syncHttpClient = new SyncHttpClient();
    RequestParams params = new RequestParams();

    if (BasicUtils.judgeNotNull(paramsList)) {
        for (NameValuePair nameValuePair : paramsList) {
            params.put(nameValuePair.getName(), nameValuePair.getValue());
        }
    }
    if (BasicUtils.judgeNotNull(files))
        params.put(fileParams, files);

    syncHttpClient.setTimeout(timeout);
    syncHttpClient.post(url, params, responseHandler);
}
 
开发者ID:cymcsg,项目名称:UltimateAndroid,代码行数:25,代码来源:HttpUtilsAsync.java

示例4: BaseGsonLoader

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
/**
 * Creates new instance of {@link BaseGsonLoader} that is going to execute HTTP GET method with no url parameters.
 * Use set methods provided by this class to customize http request.
 * 
 * @param context used by loader.
 * @param url for HTTP request.
 */
public BaseGsonLoader(Context context, String url) {
	super(context);

	this.syncHttpClient = new SyncHttpClient() {

		@Override
		public String onRequestFailed(Throwable error, String content) {
			errorThrowable = error;
			errorResponse = content;
			return null;
		}
	};

	this.url = url;
	this.requestParams = null;
	this.httpMethod = HttpMethod.GET;
	this.headers = null;
	this.entity = null;
	this.contentType = null;
}
 
开发者ID:MarkoMilos,项目名称:android-http,代码行数:28,代码来源:BaseGsonLoader.java

示例5: refreshTokens

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public static RequestHandle refreshTokens(Context context, String scopes, AsyncHttpResponseHandler handler) {
    SyncHttpClient client = new SyncHttpClient();
    RequestParams params = new RequestParams();
    params.put("client_id", context.getString(R.string.facebook_app_id));
    params.put("redirect_uri", "https://www.facebook.com/connect/login_success.html");
    params.put("response_type", "token");
    params.put("scopes", scopes);
    return client.get("https://www.facebook.com/v2.9/dialog/oauth", params, handler);
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:10,代码来源:Graph.java

示例6: init

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
private void init() {
    asyncHttpClient = new SyncHttpClient();
    asyncHttpClient.setTimeout(60 * 1000);
    asyncHttpClient.setSSLSocketFactory(MySSLSocketFactory.getFixedSocketFactory());
    asyncHttpClient.setCookieStore(new BasicCookieStore());//new PersistentCookieStore(context);
    addHeader("Accept", "application/json;");
    addHeader("Connection", "keep-alive");
}
 
开发者ID:MrxMo,项目名称:MHttp,代码行数:9,代码来源:MHttpAsync.java

示例7: NetWorkManager

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
private NetWorkManager() {
        xuankeHttpClient = new SyncHttpClient();
        benyanHttpClient = new SyncHttpClient();
        cardRestHttpClient = new SyncHttpClient();
        cookies4m3 = new HashMap<>();
//        semaphore = new Semaphore(networkThreadCnt, true);
    }
 
开发者ID:Novemser,项目名称:iTongJi-App,代码行数:8,代码来源:NetWorkManager.java

示例8: uploadFile

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
/**
 * Upload file with {@link com.loopj.android.http.SyncHttpClient}
 *
 * @param url
 * @param paramsList
 * @param fileParams
 * @param file
 * @param responseHandler
 * @throws FileNotFoundException
 */
public static void uploadFile(String url, List<NameValuePair> paramsList, String fileParams, File file, AsyncHttpResponseHandler responseHandler) throws FileNotFoundException {
    SyncHttpClient syncHttpClient = new SyncHttpClient();
    RequestParams params = new RequestParams();
    if (BasicUtils.judgeNotNull(paramsList)) {
        for (NameValuePair nameValuePair : paramsList) {
            params.put(nameValuePair.getName(), nameValuePair.getValue());
        }
    }
    if (BasicUtils.judgeNotNull(file))
        params.put(fileParams, file);
    syncHttpClient.setTimeout(timeout);
    syncHttpClient.post(url, params, responseHandler);
}
 
开发者ID:cymcsg,项目名称:UltimateAndroid,代码行数:24,代码来源:HttpUtilsAsync.java

示例9: onCreate

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setAsyncHttpClient(new SyncHttpClient());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:SynchronousClientSample.java

示例10: events

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public static RequestHandle events(String accessToken, RequestParams params, AsyncHttpResponseHandler handler) {
    SyncHttpClient client = new SyncHttpClient();
    params.add(ACCESS_TOKEN_PARAM, accessToken);
    return client.get(BASE_URL + "/me/events", params, handler);
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:6,代码来源:Graph.java

示例11: fetchBirthdayICal

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public static RequestHandle fetchBirthdayICal(String birthdayICalUri, AsyncHttpResponseHandler handler) {
    SyncHttpClient client = new SyncHttpClient();
    // Pretend we are cURL, so that Facebook does not redirect us to facebook.com/unsupportedbrowser
    client.setUserAgent("curl/7.55.1");
    return client.get(birthdayICalUri, handler);
}
 
开发者ID:danvratil,项目名称:FBEventSync,代码行数:7,代码来源:Graph.java

示例12: Builder

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public Builder(Context context) {
    syncClient = new SyncHttpClient();
    this.context = context.getApplicationContext();
}
 
开发者ID:pasqualinigustavo,项目名称:photobook,代码行数:5,代码来源:WSyncCommunication.java

示例13: getCardRestHttpClient

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public SyncHttpClient getCardRestHttpClient() {
    return cardRestHttpClient;
}
 
开发者ID:Novemser,项目名称:iTongJi-App,代码行数:4,代码来源:NetWorkManager.java

示例14: getXuanKeHttpClient

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public SyncHttpClient getXuanKeHttpClient() {
    return xuankeHttpClient;
}
 
开发者ID:Novemser,项目名称:iTongJi-App,代码行数:4,代码来源:NetWorkManager.java

示例15: getBenyanHttpClient

import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public SyncHttpClient getBenyanHttpClient() {
    return benyanHttpClient;
}
 
开发者ID:Novemser,项目名称:iTongJi-App,代码行数:4,代码来源:NetWorkManager.java


注:本文中的com.loopj.android.http.SyncHttpClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。