List of usage examples for android.net Uri getQueryParameter
@Nullable
public String getQueryParameter(String key)
From source file:Main.java
/** * Unmask the URI and return it//from w w w. java 2 s. co m */ public static Uri unmaskLink(Uri uri, int i) { String s = null; List pathSegments; if (MASK_HOSTS_SEG[i] == null) { // The host always masks, no need to determine if it's the right segment s = uri.getQueryParameter(MASK_HOSTS_PAR[i]); } else { // Only a certain segment is used to mask URLs. Determine if this is it. pathSegments = uri.getPathSegments(); if (pathSegments == null) return uri; // If it is, unmask the URL. if (pathSegments.size() > 0 && MASK_HOSTS_SEG[i].equals(pathSegments.get(0))) s = uri.getQueryParameter(MASK_HOSTS_PAR[i]); } if (s == null) return uri; // Resolve link if it's relative try { if (!new URI(s).isAbsolute()) s = new URI(uri.toString()).resolve(s).toString(); } catch (URISyntaxException e) { e.printStackTrace(); } try { return Uri.parse(URLDecoder.decode(s, "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return uri; } }
From source file:com.appnexus.opensdk.ANJAMImplementation.java
private static void callRecordEvent(AdWebView webView, Uri uri) { String urlParam = uri.getQueryParameter("url"); if ((urlParam == null) || (!urlParam.startsWith("http"))) { return;// w w w . j a v a 2s . c o m } // Create a invisible webview to fire the url WebView recordEventWebView = new WebView(webView.getContext()); recordEventWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); Clog.d(Clog.baseLogTag, "RecordEvent completed loading: " + url); CookieSyncManager csm = CookieSyncManager.getInstance(); if (csm != null) csm.sync(); } }); recordEventWebView.loadUrl(urlParam); recordEventWebView.setVisibility(View.GONE); webView.addView(recordEventWebView); }
From source file:com.appnexus.opensdk.ANJAMImplementation.java
@SuppressLint("SetJavaScriptEnabled") private static void callInternalBrowser(AdWebView webView, Uri uri) { String urlParam = uri.getQueryParameter("url"); if ((webView.getContext() == null) || (urlParam == null) || (!urlParam.startsWith("http"))) { return;/* ww w. j a va2 s.co m*/ } String url = Uri.decode(urlParam); Class<?> activity_clz = AdActivity.getActivityClass(); Intent intent = new Intent(webView.getContext(), activity_clz); intent.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_BROWSER); WebView browserWebView = new WebView(webView.getContext()); WebviewUtil.setWebViewSettings(browserWebView); BrowserAdActivity.BROWSER_QUEUE.add(browserWebView); browserWebView.loadUrl(url); if (webView.adView.getBrowserStyle() != null) { String i = "" + browserWebView.hashCode(); intent.putExtra("bridgeid", i); AdView.BrowserStyle.bridge .add(new Pair<String, AdView.BrowserStyle>(i, webView.adView.getBrowserStyle())); } try { webView.getContext().startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(webView.getContext(), R.string.action_cant_be_completed, Toast.LENGTH_SHORT).show(); Clog.w(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName())); BrowserAdActivity.BROWSER_QUEUE.remove(); } }
From source file:com.appnexus.opensdk.ANJAMImplementation.java
private static void callMayDeepLink(WebView webView, Uri uri) { boolean mayDeepLink; String cb = uri.getQueryParameter("cb"); String urlParam = uri.getQueryParameter("url"); if ((webView.getContext() == null) || (webView.getContext().getPackageManager() == null) || (urlParam == null)) {/*from w ww.jav a2 s .c o m*/ mayDeepLink = false; } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Uri.decode(urlParam))); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mayDeepLink = intent.resolveActivity(webView.getContext().getPackageManager()) != null; } LinkedList<BasicNameValuePair> list = new LinkedList<BasicNameValuePair>(); list.add(new BasicNameValuePair(KEY_CALLER, CALL_MAYDEEPLINK)); list.add(new BasicNameValuePair("mayDeepLink", String.valueOf(mayDeepLink))); loadResult(webView, cb, list); }
From source file:org.alfresco.mobile.android.api.session.authentication.impl.OAuthHelper.java
/** * Retrieve the authorization code from the url callback uri. <br/> * If user has access, Alfresco grant access and invoke the callback URI * with the authorization code./* w w w . j av a 2s . c o m*/ * * @param url : Callback uri that contains authorization code. * @return authorization code. */ public static String retrieveCode(String url) { Uri uri = Uri.parse(url); return uri.getQueryParameter("code"); }
From source file:com.github.notizklotz.derbunddownloader.download.IssueDownloadService.java
public static Uri getThumbnailUriForPDFUri(Uri pdfUri) { String ddmmyyyy = pdfUri.getQueryParameter("ausgabe"); int day = Integer.parseInt(ddmmyyyy.substring(0, 2)); int month = Integer.parseInt(ddmmyyyy.substring(2, 4)); int year = Integer.parseInt(ddmmyyyy.substring(4, 8)); return Uri.parse(String.format(ISSUE_THUMBNAIL_URL_TEMPLATE, year, day, month)); }
From source file:Main.java
public static List<String> getJoins(Uri uri) { List<String> result = new ArrayList<String>(); Set<String> queryParameterNames = getQueryParameterNames(uri); Iterator<String> iterator = queryParameterNames.iterator(); while (iterator.hasNext()) { String param = iterator.next(); if (param.startsWith(TABLE)) { result.add(uri.getQueryParameter(param)); }// w ww .jav a2s .c om } return result; }
From source file:com.appnexus.opensdk.PBImplementation.java
static void handleUrl(AdWebView adWebView, String url) { if ((adWebView == null) || (adWebView.getContext() == null)) { return;// w w w . j av a2 s. com } Context context = adWebView.getContext(); Uri uri = Uri.parse(url); String host = uri.getHost(); if (HOST_WEB.equals(host)) { if (adWebView.getUserInteraction()) { launchApp(context); } } else if (HOST_APP.equals(host)) { String auctionInfo = uri.getQueryParameter(KEY_AUCTIONINFO); saveAuctionInfo(auctionInfo); } else if (HOST_CAPTURE.equals(host)) { String auctionID = uri.getQueryParameter(KEY_AUCTIONID); String auctionInfo = buffer.get(auctionID); if (auctionInfo == null) { return; } captureImage(context, adWebView, auctionInfo); } }
From source file:me.zhang.bingo.Utility.java
public static String extractQueryParam(String url) { Uri uri = Uri.parse(url); String query = uri.getQueryParameter("q"); Timber.i("query -> " + query); return query; }
From source file:edu.mit.mobile.android.locast.data.TaggableItem.java
/** * Given a URI that includes a set of tags, parses them out and returns them as a set. * //from w ww . ja va 2 s . c om * @param contentUri * @return the set of tags encoded in the URI * @throws IllegalArgumentException * if the URI doesn't contain a tag query string */ public static Set<String> getTagsFromUri(Uri contentUri) throws IllegalArgumentException { final String query = contentUri.getQueryParameter(SERVER_QUERY_PARAMETER); if (query == null) { throw new IllegalArgumentException("uri doesn't contain any tags"); } return Tag.toSet(query); }