List of usage examples for org.apache.http.protocol HTTP PLAIN_TEXT_TYPE
String PLAIN_TEXT_TYPE
To view the source code for org.apache.http.protocol HTTP PLAIN_TEXT_TYPE.
Click Source Link
From source file:at.wada811.utils.IntentUtils.java
/** * ??Intent??//w w w.j a v a 2 s . co m * * @param mailto * @param cc * @param bcc * @param subject * @param body */ public static Intent createSendMailIntent(String[] mailto, String[] cc, String[] bcc, String subject, String body) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(HTTP.PLAIN_TEXT_TYPE); intent.putExtra(Intent.EXTRA_EMAIL, mailto); intent.putExtra(Intent.EXTRA_CC, cc); intent.putExtra(Intent.EXTRA_BCC, bcc); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); return intent; }
From source file:com.battlelancer.seriesguide.ui.HelpActivity.java
private void sendEmail() { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType(HTTP.PLAIN_TEXT_TYPE); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { SeriesGuidePreferences.SUPPORT_MAIL }); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "SeriesGuide " + Utils.getVersion(this) + " Feedback"); intent.putExtra(android.content.Intent.EXTRA_TEXT, ""); Intent chooser = Intent.createChooser(intent, getString(R.string.feedback)); Utils.tryStartActivity(this, chooser, true); }
From source file:com.ibm.watson.developer_cloud.personality_insights.v2.PersonalityInsights.java
/** * Accepts text or a {@link Content} object and responds with a {@link Profile} * with a tree of characteristics that include personality, needs, and values. * If you include either created or updated timestamps, the response also includes * a summary of the author's writing habits with respect to time of day. * //from w w w . j av a2 s .co m * @param params * The parameters to generate the profile. Either text or content need * to be specified * @return The personality profile */ public Profile getProfile(final Map<String, Object> params) { if (!params.containsKey(TEXT) && !params.containsKey(CONTENT)) throw new IllegalArgumentException("text or content need to be specified"); else if (params.containsKey(TEXT) && params.containsKey(CONTENT)) log.warning("text and content were specified, only text will be used"); Request request = Request.Post("/v2/profile"); if (params.containsKey(TEXT)) { request.withContent(params.get(TEXT).toString(), HTTP.PLAIN_TEXT_TYPE); } else { String contentJson = GsonSingleton.getGson().toJson(params.get(CONTENT)); request.withContent(contentJson, MediaType.APPLICATION_JSON); } if (params.containsKey(INCLUDE_RAW)) request.withQuery(INCLUDE_RAW, params.get(INCLUDE_RAW)); if (params.containsKey(LANGUAGE)) request.withHeader(HttpHeaders.CONTENT_LANGUAGE, params.get(LANGUAGE)); if (params.containsKey(ACCEPT_LANGUAGE)) request.withHeader(HttpHeaders.ACCEPT_LANGUAGE, params.get(ACCEPT_LANGUAGE)); HttpResponse response = execute(request.build()); try { String profileJson = ResponseUtil.getString(response); Profile profile = GsonSingleton.getGson().fromJson(profileJson, Profile.class); return profile; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.sumologic.log4j.SumoLogicAppender.java
private void sendToSumo(String log) { HttpPost post = null;/*from w w w . j a v a 2 s . co m*/ try { post = new HttpPost(url); post.setEntity(new StringEntity(log, HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8)); HttpResponse response = httpClient.execute(post); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { LogLog.warn(String.format("Received HTTP error from Sumo Service: %d", statusCode)); } //need to consume the body if you want to re-use the connection. EntityUtils.consume(response.getEntity()); } catch (IOException e) { LogLog.warn("Could not send log to Sumo Logic", e); try { post.abort(); } catch (Exception ignore) { } } }
From source file:com.sumologic.logback.SumoLogicAppender.java
private void sendToSumo(String data) { HttpPost post = null;//from w w w .j ava 2 s . c o m try { post = new HttpPost(url); post.setEntity(new StringEntity(data, HTTP.PLAIN_TEXT_TYPE, HTTP.UTF_8)); HttpResponse response = httpClient.execute(post); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != 200) { log.warn("Received HTTP error from Sumo Service: {}", statusCode); } //need to consume the body if you want to re-use the connection. EntityUtils.consume(response.getEntity()); } catch (IOException e) { log.warn("Could not send log to Sumo Logic", e); try { post.abort(); } catch (Exception ignore) { } } }
From source file:com.digitalarx.android.files.FileOperationsHelper.java
private Intent createShareWithLinkIntent(String link) { Intent intentToShareLink = new Intent(Intent.ACTION_SEND); intentToShareLink.putExtra(Intent.EXTRA_TEXT, link); intentToShareLink.setType(HTTP.PLAIN_TEXT_TYPE); return intentToShareLink; }
From source file:im.delight.android.baselib.Social.java
/** * Constructs an SMS Intent for the given message details and opens the application chooser for this Intent * * @param recipient the recipient's phone number or `null` * @param body the body of the message//from w w w . j a va2 s . c o m * @param captionRes the string resource ID for the application chooser's window title * @param context the Context instance to start the Intent from * @throws Exception if there was an error trying to launch the SMS Intent */ public static void sendSMS(final String recipient, final String body, final int captionRes, final Context context) throws Exception { final Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType(HTTP.PLAIN_TEXT_TYPE); if (recipient != null && recipient.length() > 0) { intent.setData(Uri.parse("smsto:" + recipient)); } else { intent.setData(Uri.parse("sms:")); } intent.putExtra("sms_body", body); intent.putExtra(Intent.EXTRA_TEXT, body); if (context != null) { // offer a selection of all applications that can handle the SMS Intent context.startActivity(Intent.createChooser(intent, context.getString(captionRes))); } }
From source file:im.delight.android.commons.Social.java
/** * Displays an application chooser and composes the described text message (SMS) using the selected application * * @param recipientPhone the recipient's phone number or `null` * @param bodyText the body text of the message * @param captionRes a string resource ID for the title of the application chooser's window * @param context a context reference/*from www . j a va2 s.c om*/ * @throws Exception if there was an error trying to launch the SMS application */ public static void sendSms(final String recipientPhone, final String bodyText, final int captionRes, final Context context) throws Exception { final Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType(HTTP.PLAIN_TEXT_TYPE); if (recipientPhone != null && recipientPhone.length() > 0) { intent.setData(Uri.parse("smsto:" + recipientPhone)); } else { intent.setData(Uri.parse("sms:")); } intent.putExtra("sms_body", bodyText); intent.putExtra(Intent.EXTRA_TEXT, bodyText); if (context != null) { // offer a selection of all applications that can handle the SMS Intent context.startActivity(Intent.createChooser(intent, context.getString(captionRes))); } }
From source file:com.googlecode.osde.internal.igoogle.IgHostingUtil.java
/** * Sends HTTP request to iGoogle server and retrieves response * content as String./* w w w . j a va 2s . c o m*/ * * @return response as String * @throws IgException */ static String retrieveHttpResponseAsString(String url, String sid) throws IgException { // Prepare HttpGet. HttpGet httpGet = new HttpGet(url); httpGet.setHeader(HTTP.CONTENT_TYPE, HTTP.PLAIN_TEXT_TYPE); httpGet.addHeader(IgHttpUtil.HTTP_HEADER_COOKIE, "SID=" + sid); // Retrieve HttpResponse. HttpClient httpClient = new DefaultHttpClient(); HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet); } catch (ClientProtocolException e) { throw new IgException(e); } catch (IOException e) { throw new IgException(e); } logger.fine("status line: " + httpResponse.getStatusLine()); return IgHttpUtil.retrieveHttpResponseAsString(httpClient, httpGet, httpResponse); }