List of usage examples for android.net Uri getQueryParameters
public List<String> getQueryParameters(String key)
From source file:com.facebook.stetho.dumpapp.DumpappHandler.java
protected static String[] getArgs(HttpRequest request) { Uri requestUri = Uri.parse(request.getRequestLine().getUri()); List<String> argsList = requestUri.getQueryParameters(QUERY_PARAM_ARGV); return argsList.toArray(new String[argsList.size()]); }
From source file:org.webpki.mobile.android.proxy.BaseProxyActivity.java
public void getProtocolInvocationData() throws Exception { logOK(getProtocolName() + " protocol run: " + new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(new Date())); protocol_log = new Vector<byte[]>(); https_wrapper = new HTTPSWrapper(); initSKS();/* w w w. j ava 2s.co m*/ schema_cache = new JSONDecoderCache(); Intent intent = getIntent(); Uri uri = intent.getData(); if (uri == null) { throw new IOException("No URI"); } List<String> arg = uri.getQueryParameters("url"); if (arg.isEmpty()) { throw new IOException("Missing initialization \"url\""); } requesting_host = new URL(initialization_url = arg.get(0)).getHost(); arg = uri.getQueryParameters("cookie"); if (!arg.isEmpty()) { cookies.add(arg.get(0)); } logOK("Invocation URL=" + initialization_url + ", Cookie: " + (arg.isEmpty() ? "N/A" : cookies.elementAt(0))); addOptionalCookies(initialization_url); int ver_index; if ((ver_index = initialization_url.indexOf(VERSION_MACRO)) > 0) { initialization_url = initialization_url.substring(0, ver_index) + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + initialization_url.substring(ver_index + VERSION_MACRO.length()); } https_wrapper.makeGetRequest(initialization_url); if (https_wrapper.getResponseCode() == HttpStatus.SC_OK) { initial_request_object = https_wrapper.getData(); server_certificate = https_wrapper.getServerCertificate(); checkContentType(); } else if (https_wrapper.getResponseCode() == HttpStatus.SC_MOVED_TEMPORARILY) { if ((redirect_url = https_wrapper.getHeaderValue("Location")) == null) { throw new IOException("Malformed redirect"); } init_rejected = true; } else { throw new IOException(https_wrapper.getResponseMessage()); } }
From source file:net.eledge.android.europeana.gui.activity.SearchActivity.java
private void handleIntent(Intent intent) { String query = null;/*from ww w. ja v a2s . c om*/ String[] qf = null; if (intent != null) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { query = intent.getStringExtra(SearchManager.QUERY); qf = splitFacets(intent.getStringExtra(SearchManager.USER_QUERY)); } else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { Parcelable[] parcelables = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage msg = (NdefMessage) parcelables[0]; Uri uri = Uri.parse(new String(msg.getRecords()[0].getPayload())); query = uri.getQueryParameter("query"); qf = StringArrayUtils.toArray(uri.getQueryParameters("qf")); } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { query = intent.getDataString(); if (!TextUtils.isEmpty(query)) { if (StringUtils.contains(query, "europeana.eu/")) { Uri uri = Uri.parse(query); query = uri.getQueryParameter("query"); qf = StringArrayUtils.toArray(uri.getQueryParameters("qf")); } } } else { // no search action recognized? end this activity... closeSearchActivity(); } if (!TextUtils.isEmpty(query) && !TextUtils.equals(runningSearch, query)) { runningSearch = query; if (StringArrayUtils.isNotBlank(qf)) { searchController.newSearch(this, query, qf); } else { searchController.newSearch(this, query); } getSupportActionBar().setTitle(searchController.getSearchTitle(this)); } } }
From source file:com.android.mail.compose.ComposeActivity.java
/** * Initialize the compose view from a String representing a mailTo uri. * @param mailToString The uri as a string. *//* www . ja va 2 s. c o 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 */); } }
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. *//* ww w. ja v a 2 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 } }