List of usage examples for android.text TextUtils split
public static String[] split(String text, Pattern pattern)
From source file:com.tct.mail.compose.ComposeActivity.java
/** * Initialize the compose view from a String representing a mailTo uri. * @param mailToString The uri as a string. *//*from w w w . jav a2 s. co m*/ public void initFromMailTo(String mailToString) { // We need to disguise this string as a URI in order to parse it // TODO: Remove this hack when http://b/issue?id=1445295 gets fixed Uri uri = Uri.parse("foo://" + mailToString); int index = mailToString.indexOf("?"); int length = "mailto".length() + 1; String to; try { // Extract the recipient after mailto: if (index == -1) { to = decodeEmailInUri(mailToString.substring(length)); } else { to = decodeEmailInUri(mailToString.substring(length, index)); } if (!TextUtils.isEmpty(to)) { addToAddresses(Arrays.asList(TextUtils.split(to, ","))); } } catch (UnsupportedEncodingException e) { if (LogUtils.isLoggable(LOG_TAG, LogUtils.VERBOSE)) { LogUtils.e(LOG_TAG, "%s while decoding '%s'", e.getMessage(), mailToString); } else { LogUtils.e(LOG_TAG, e, "Exception while decoding mailto address"); } } List<String> cc = uri.getQueryParameters("cc"); addCcAddresses(Arrays.asList(cc.toArray(new String[cc.size()])), null); List<String> otherTo = uri.getQueryParameters("to"); addToAddresses(Arrays.asList(otherTo.toArray(new String[otherTo.size()]))); List<String> bcc = uri.getQueryParameters("bcc"); addBccAddresses(Arrays.asList(bcc.toArray(new String[bcc.size()]))); // NOTE: Uri.getQueryParameters already decodes % encoded characters List<String> subject = uri.getQueryParameters("subject"); if (subject.size() > 0) { mSubject.setText(decodeContentFromQueryParam(subject.get(0))); } List<String> body = uri.getQueryParameters("body"); if (body.size() > 0) { setBody(decodeContentFromQueryParam(body.get(0)), true /* with signature */); mBodyAlreadySet = true;//[BUGFIX]-ADD by TSNJ,wenlu.wu,10/20/2014,FR-739335 } }