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


Java Method类代码示例

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


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

示例1: send

import org.acra.sender.HttpSender.Method; //导入依赖的package包/类
@Override
public void send(CrashReportData report) throws ReportSenderException {
    Uri formUri = mFormUri == null ? Uri.parse(String.format(ACRA.getConfig().googleFormUrlFormat(), ACRA
            .getConfig().formKey())) : mFormUri;
    final Map<String, String> formParams = remap(report);
    // values observed in the GoogleDocs original html form
    formParams.put("pageNumber", "0");
    formParams.put("backupCache", "");
    formParams.put("submit", "Envoyer");

    try {
        final URL reportUrl = new URL(formUri.toString());
        Log.d(LOG_TAG, "Sending report " + report.get(ReportField.REPORT_ID));
        Log.d(LOG_TAG, "Connect to " + reportUrl);

        final HttpRequest request = new HttpRequest();
        request.setConnectionTimeOut(ACRA.getConfig().connectionTimeout());
        request.setSocketTimeOut(ACRA.getConfig().socketTimeout());
        request.setMaxNrRetries(ACRA.getConfig().maxNumberOfRequestRetries());
        request.send(reportUrl, Method.POST, HttpRequest.getParamsAsFormString(formParams), Type.FORM);

    } catch (IOException e) {
        throw new ReportSenderException("Error while sending report to Google Form.", e);
    }
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:26,代码来源:GoogleFormSender.java

示例2: httpMethod

import org.acra.sender.HttpSender.Method; //导入依赖的package包/类
@Override
public Method httpMethod() {
    if (mHttpMethod != null) {
        return mHttpMethod;
    }

    if (mReportsCrashes != null) {
        return mReportsCrashes.httpMethod();
    }

    return Method.POST;
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:13,代码来源:ACRAConfiguration.java

示例3: getHttpRequest

import org.acra.sender.HttpSender.Method; //导入依赖的package包/类
private HttpEntityEnclosingRequestBase getHttpRequest(URL url, Method method, String content, Type type)
        throws UnsupportedEncodingException, UnsupportedOperationException {

    final HttpEntityEnclosingRequestBase httpRequest;
    switch (method) {
    case POST:
        httpRequest = new HttpPost(url.toString());
        break;
    case PUT:
        httpRequest = new HttpPut(url.toString());
        break;
    default:
        throw new UnsupportedOperationException("Unknown method: " + method.name());
    }

    final UsernamePasswordCredentials creds = getCredentials();
    if (creds != null) {
        httpRequest.addHeader(BasicScheme.authenticate(creds, "UTF-8", false));
    }
    httpRequest.setHeader("User-Agent", "Android");
    httpRequest
            .setHeader("Accept",
                    "text/html,application/xml,application/json,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
    httpRequest.setHeader("Content-Type", type.getContentType());

    if(headers !=null) {
       Iterator<String> headerIt = headers.keySet().iterator();
       while(headerIt.hasNext()) {
          String header = headerIt.next();
          String value = headers.get(header);
          httpRequest.setHeader(header, value);
       }
    }
    
    httpRequest.setEntity(new StringEntity(content, "UTF-8"));

    return httpRequest;
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:39,代码来源:HttpRequest.java

示例4: setHttpMethod

import org.acra.sender.HttpSender.Method; //导入依赖的package包/类
/**
 * 
 * @param httpMethod
 *            The method to be used to send data to the server.
 */
public ACRAConfiguration setHttpMethod(Method httpMethod) {
    mHttpMethod = httpMethod;
    return this;
}
 
开发者ID:cheyiliu,项目名称:test4android,代码行数:10,代码来源:ACRAConfiguration.java


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