Java Code Examples for android.net.Uri#getQuery()
The following examples show how to use
android.net.Uri#getQuery() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IceCreamCordovaWebViewClient.java From wildfly-samples with MIT License | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 2
Source File: SystemWebViewClient.java From a2cardboard with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 3
Source File: IceCreamCordovaWebViewClient.java From IoTgo_Android_App with MIT License | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 4
Source File: SystemWebViewClient.java From chappiecast with Mozilla Public License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 5
Source File: IceCreamCordovaWebViewClient.java From crosswalk-cordova-android with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 6
Source File: IceCreamCordovaWebViewClient.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 7
Source File: X5WebViewClient.java From x5webview-cordova-plugin with Apache License 2.0 | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(Build.VERSION.SDK_INT){ case Build.VERSION_CODES.ICE_CREAM_SANDWICH: case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 8
Source File: IceCreamCordovaWebViewClient.java From phonegapbootcampsite with MIT License | 6 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } switch(android.os.Build.VERSION.SDK_INT){ case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH: case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1: return true; } return false; }
Example 9
Source File: CustomMatchers.java From OpenYOLO-Android with Apache License 2.0 | 6 votes |
@Override protected boolean matchesSafely(Uri item) { if (!item.isAbsolute() || !item.isHierarchical() || TextUtils.isEmpty(item.getScheme()) || TextUtils.isEmpty(item.getAuthority())) { return false; } if (!mPermittedSchemes.isEmpty() && !mPermittedSchemes.contains(item.getScheme())) { return false; } if (mAllowPathQueryOrFragment) { return true; } return TextUtils.isEmpty(item.getPath()) && item.getQuery() == null && item.getFragment() == null; }
Example 10
Source File: ModelWrapper.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Inserts or updates and returns * @param uri * @param values * @param resolver * @return */ public static synchronized Uri getOrCreate(Uri uri, ContentValues values, ContentResolver resolver) { Uri result = Uri.EMPTY; Cursor c = null; int updated = 0; boolean created = false; switch (Uris.getTypeDescriptor(uri)) { case Uris.ITEM_UUID: case Uris.ITEM_ID: if (Uris.isEmpty(exists(resolver, uri, null, null))) { updated = resolver.update(uri, values, null, null); } else { throw new IllegalArgumentException("Error updating. Item does not exist: " + uri); } break; case Uris.ITEMS: if (uri.getQuery() != null) { String uuid = uri.getQueryParameter(BaseContract.UUID); String selection = BaseContract.UUID + "=?"; String[] selectionArgs = new String[]{uuid}; result = exists(resolver, uri, selection, selectionArgs); if (!Uris.isEmpty(result)) { resolver.update(uri, values, null, null); } else { result = resolver.insert(uri, values); } } else { result = resolver.insert(uri, values); } break; default: throw new IllegalArgumentException("Error updating. Unrecognized uri: " + uri); } return result; }
Example 11
Source File: TestContentProvider.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { String action = uri.getLastPathSegment(); String resource = uri.getQuery(); if (GET_RESOURCE_REQUEST_COUNT.equals(action)) { return new ProviderStateCursor( mResourceRequestCount.containsKey(resource) ? mResourceRequestCount.get(resource) : 0); } else if (RESET_RESOURCE_REQUEST_COUNT.equals(action)) { mResourceRequestCount.put(resource, 0); } return null; }
Example 12
Source File: HttpTransaction.java From chuck with Apache License 2.0 | 5 votes |
public void setUrl(String url) { this.url = url; Uri uri = Uri.parse(url); host = uri.getHost(); path = uri.getPath() + ((uri.getQuery() != null) ? "?" + uri.getQuery() : ""); scheme = uri.getScheme(); }
Example 13
Source File: MainActivity.java From AndroidHttpCapture with MIT License | 5 votes |
/** * 启动的时候根据bundle参数决定切换到哪个tab */ private void handleUriStartupParams() { Intent intent = getIntent(); if (intent == null) { return; } Uri uri = intent.getData(); if (uri == null) { return; } // 这里要把data置空,否则每次进来锁屏解锁,都会触发这些逻辑 intent.setData(null); String query = uri.getQuery(); // "param="这个字符串已经占了6个字符了,所以query的长度至少要有8(加上花括号) if (query == null || query.length() < 8) { return; } try { // 通过uri.getQuery()得到的query已经是解码过的字符串了,不需要再decode String jsonString = query.substring(6); JSONObject json = new JSONObject(jsonString); WebViewFragment webViewFragment = WebViewFragment.getInstance(); webViewFragment.loadUrl(json.getString("url")); switchContent(webViewFragment); } catch (Exception e) { e.printStackTrace(); } }
Example 14
Source File: ActivityDelegate.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Parse out the URL for a document Intent. * @param intent Intent to check. * @return The URL that the Intent was fired to display, or null if it couldn't be retrieved. */ public static String getInitialUrlForDocument(Intent intent) { if (intent == null || intent.getData() == null) return null; Uri data = intent.getData(); return TextUtils.equals(data.getScheme(), UrlConstants.DOCUMENT_SCHEME) ? data.getQuery() : null; }
Example 15
Source File: SystemWebViewClient.java From keemob with MIT License | 5 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } return false; }
Example 16
Source File: SystemWebViewClient.java From keemob with MIT License | 5 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } return false; }
Example 17
Source File: SystemWebViewClient.java From countly-sdk-cordova with MIT License | 5 votes |
private static boolean needsSpecialsInAssetUrlFix(Uri uri) { if (CordovaResourceApi.getUriType(uri) != CordovaResourceApi.URI_TYPE_ASSET) { return false; } if (uri.getQuery() != null || uri.getFragment() != null) { return true; } if (!uri.toString().contains("%")) { return false; } return false; }
Example 18
Source File: SearchPostFragment.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
@Override public boolean shouldOverrideUrlLoading(WebView view, final String url) { if (url.contains("HTMLOUT.ru")) { Uri uri = Uri.parse(url); try { String function = uri.getPathSegments().get(0); String query = uri.getQuery(); Class[] parameterTypes = null; String[] parameterValues = new String[0]; if (!TextUtils.isEmpty(query)) { Matcher m = Pattern.compile("(.*?)=(.*?)(&|$)").matcher(query); ArrayList<String> objs = new ArrayList<>(); while (m.find()) { objs.add(m.group(2)); } parameterValues = new String[objs.size()]; parameterTypes = new Class[objs.size()]; for (int i = 0; i < objs.size(); i++) { parameterTypes[i] = String.class; parameterValues[i] = objs.get(i); } } Method method = this.getClass().getMethod(function, parameterTypes); method.invoke(getMainActivity(), (Object[]) parameterValues); } catch (Exception e) { e.printStackTrace(); } return true; } IntentActivity.tryShowUrl((Activity) getContext(), mHandler, url, true, false); return true; }
Example 19
Source File: ThemeFragment.java From 4pdaClient-plus with Apache License 2.0 | 4 votes |
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!startsWith(url, mUrl) && !mLoadingFinished) { if (url.contains("HTMLOUT.ru")) { Uri uri = Uri.parse(url); try { String function = uri.getPathSegments().get(0); String query = uri.getQuery(); Class[] parameterTypes = null; String[] parameterValues = new String[0]; if (!TextUtils.isEmpty(query)) { Matcher m = Pattern.compile("(.*?)=(.*?)(&|$)").matcher(url); ArrayList<String> objs = new ArrayList<>(); while (m.find()) { objs.add(Uri.decode(m.group(2))); } parameterValues = new String[objs.size()]; parameterTypes = new Class[objs.size()]; for (int i = 0; i < objs.size(); i++) { parameterTypes[i] = String.class; parameterValues[i] = objs.get(i); } } ThemeFragment.class.getMethod(function, parameterTypes).invoke(getMainActivity(), (Object[]) parameterValues); } catch (Exception e) { AppLog.eToast(getMainActivity(), e); } return true; } mUrl = null; onPageStarted(view, url, null); } m_ScrollY = 0; if (checkIsImage(url)) return true; if (checkIsTheme(url)) return true; if (checkIsPoll(url)) return true; if (tryDeletePost(url)) return true; if (tryQuote(url)) return true; IntentActivity.tryShowUrl(getMainActivity(), mHandler, url, true, false, m_Topic == null ? null : Client.getInstance().getAuthKey()); return true; }
Example 20
Source File: UrlUtils.java From YCAudioPlayer with Apache License 2.0 | 4 votes |
/** * 拼接字符串 * @param url url * @param map map集合 * @return */ public static String getUrl(String url, HashMap<String, String> map){ if(TextUtils.isEmpty(url)){ return null; } //解析一个url Uri uri = Uri.parse(url); // 完整的url信息 String urlStr = uri.toString(); Log.e( "UrlUtils","url: " + urlStr); // scheme部分 String scheme = uri.getScheme(); Log.e( "UrlUtils","scheme: " + scheme); // host部分 String host = uri.getHost(); Log.e( "UrlUtils","host: " + host); //port部分 int port = uri.getPort(); Log.e( "UrlUtils","port: " + port); // 访问路劲 String path = uri.getPath(); Log.e( "UrlUtils","path: " + path); List<String> pathSegments = uri.getPathSegments(); Log.e( "UrlUtils","pathSegments: " + pathSegments.toString()); // Query部分 String query = uri.getQuery(); Log.e( "UrlUtils","query: " + query); //获取此URI的解码权限部分。对于服务器地址,权限的结构如下:Examples: "google.com", "[email protected]:80" String authority = uri.getAuthority(); Log.e( "UrlUtils","authority: " + authority); //从权限获取已解码的用户信息。例如,如果权限为“任何人@google.com”,此方法将返回“任何人”。 String userInfo = uri.getUserInfo(); Log.e( "UrlUtils","userInfo: " + userInfo); //UrlUtils: url: https://m.dev.haowumc.com/app/financialManagement //UrlUtils: scheme: https //UrlUtils: host: m.dev.haowumc.com //UrlUtils: port: -1 //UrlUtils: path: /app/financialManagement //UrlUtils: pathSegments: [app, financialManagement] //UrlUtils: query: null //UrlUtils: authority: m.dev.haowumc.com //UrlUtils: userInfo: null Uri.Builder builder = uri.buildUpon(); if (map != null && map.size() > 0) { //使用迭代器进行遍历 for (Object o : map.entrySet()) { Map.Entry entry = (Map.Entry) o; String key = (String) entry.getKey(); String value = (String) entry.getValue(); //对键和值进行编码,然后将参数追加到查询字符串中。 builder.appendQueryParameter(key, value); } } return builder.toString(); }