本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例9: onCreate
import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setAsyncHttpClient(new SyncHttpClient());
}
示例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);
}
示例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);
}
示例12: Builder
import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public Builder(Context context) {
syncClient = new SyncHttpClient();
this.context = context.getApplicationContext();
}
示例13: getCardRestHttpClient
import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public SyncHttpClient getCardRestHttpClient() {
return cardRestHttpClient;
}
示例14: getXuanKeHttpClient
import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public SyncHttpClient getXuanKeHttpClient() {
return xuankeHttpClient;
}
示例15: getBenyanHttpClient
import com.loopj.android.http.SyncHttpClient; //导入依赖的package包/类
public SyncHttpClient getBenyanHttpClient() {
return benyanHttpClient;
}