@Override public String getType(Uri uri) { return uri.getQueryParameter("mime_type"); }
private static Map<String, String> parseParamsForGet(HttpRequest request) { Uri uri = Uri.parse(request.getRequestLine().getUri()); Set<String> paramNames = uri.getQueryParameterNames(); LinkedHashMap<String, String> map = new LinkedHashMap<>(); for (String paramName : paramNames) { map.put(paramName, uri.getQueryParameter(paramName)); } return map; } }
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) { List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS); if (formats != null && formats.size() == 1 && formats.get(0) != null){ formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); } return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE)); }
@Override public String getType(Uri uri) { return uri.getQueryParameter("mime_type"); }
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) { List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS); if (formats != null && formats.size() == 1 && formats.get(0) != null){ formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); } return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE)); }
Intent intent = getIntent(); // check if this intent is started via custom scheme link if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri uri = intent.getData(); // may be some test here with your custom uri String var = uri.getQueryParameter("var"); // "str" is set String varr = uri.getQueryParameter("varr"); // "string" is set }
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) { List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS); if (formats != null && formats.size() == 1 && formats.get(0) != null) { formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); } return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE)); }
Intent intent = getIntent(); if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri uri = intent.getData(); String valueOne = uri.getQueryParameter("keyOne"); String valueTwo = uri.getQueryParameter("keyTwo"); }
static Set<BarcodeFormat> parseDecodeFormats(Uri inputUri) { List<String> formats = inputUri.getQueryParameters(Intents.Scan.FORMATS); if (formats != null && formats.size() == 1 && formats.get(0) != null) { formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); } return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE)); }
// query code Uri queryUri = Uri.parse("content://what/ever/items"); queryUri = queryUri.buildUpon().appendQueryParameter("limit", "5").build(); // in ContentProvider String limit = queryUri.getQueryParameter("limit");
/** * Determines if the given URI specifies that the request is coming from the sync adapter. * @param uri the given URI * @return true if the uri specifies that the request is coming from the sync adapter */ private boolean callerIsSyncAdapter(Uri uri) { final String is_sync_adapter = uri.getQueryParameter(CALLER_IS_SYNC_ADAPTER); return is_sync_adapter != null && !is_sync_adapter.equals("0"); }
/** * checks the uri for the backup param. default is that * * @param uri contentUri * @return default true or false for {@code /the/uri&backup=false} */ boolean shouldBackup(@NonNull final Uri uri) { final String backup = uri.getQueryParameter("backup"); return !"false".equals(backup); }
public static Uri getMimeTypeUri(Uri contentUri, String mimeType) { if (!AUTHORITY.equals(contentUri.getAuthority())) { throw new IllegalArgumentException("Can only call this method for URIs within this authority!"); } if (contentUri.getQueryParameter("mime_type") != null) { throw new IllegalArgumentException("Can only call this method for not yet typed URIs!"); } return contentUri.buildUpon().appendQueryParameter("mime_type", mimeType).build(); }
public static String getDataUriId(@NonNull Intent intent, String altParamId) { if (intent.getData() == null) { return null; } if (TextUtils.equals(intent.getData().getScheme(), BuildConfig.APPLICATION_ID)) { return intent.getData().getLastPathSegment(); } else { // web URI return intent.getData().getQueryParameter(altParamId); } }
private String getUrl(Uri uri) { String url = uri.toString(); String scheme = uri.getScheme(); if (uri.isHierarchical()) { if (TextUtils.equals(scheme, "http") || TextUtils.equals(scheme, "https")) { String weexTpl = uri.getQueryParameter(Constants.WEEX_TPL_KEY); if (!TextUtils.isEmpty(weexTpl)) { url = weexTpl; } } } return url; }
private int getAppLinkGesture(Intent intent) { Uri targetURI = AppLinks.getTargetUrlFromInboundIntent(this, intent); if (targetURI == null) { return INVALID_CHOICE; } String gesture = targetURI.getQueryParameter("gesture"); if (gesture != null) { if (gesture.equalsIgnoreCase(getString(R.string.rock))) { return RpsGameUtils.ROCK; } else if (gesture.equalsIgnoreCase(getString(R.string.paper))) { return RpsGameUtils.PAPER; } else if (gesture.equalsIgnoreCase(getString(R.string.scissors))) { return RpsGameUtils.SCISSORS; } } return INVALID_CHOICE; }
@Test public void getQueryParameter_shouldWork() throws Exception { Uri testUri = Uri.parse("http://someplace.com:8080/a/path?param=value&another_param=another_value#top"); assertThat(testUri.getQueryParameter("param")).isEqualTo("value"); } }
@Override public AssetFileDescriptor openAssetFile(@NonNull Uri uri, @NonNull String mode) throws FileNotFoundException { if (uri.getPath() == null) { return null; } try { String fileName = getFileName(uri); boolean pipeMode = uri.getQueryParameter(PARAM_PIPE_MODE) != null; if (pipeMode) { ParcelFileDescriptor fileDescriptor = openPipeHelper(uri, null, null, null, this); return new AssetFileDescriptor(fileDescriptor, 0, C.LENGTH_UNSET); } else { return getContext().getAssets().openFd(fileName); } } catch (IOException e) { FileNotFoundException exception = new FileNotFoundException(e.getMessage()); exception.initCause(e); throw exception; } }
@Test public void testSingleGetToHttpRequest() throws Exception { GraphRequest requestMe = new GraphRequest(null, "TourEiffel"); HttpURLConnection connection = GraphRequest.toHttpConnection(requestMe); assertTrue(connection != null); assertEquals("GET", connection.getRequestMethod()); assertEquals("/" + FacebookSdk.getGraphApiVersion() + "/TourEiffel", connection.getURL().getPath()); assertTrue(connection.getRequestProperty("User-Agent").startsWith("FBAndroidSDK")); Uri uri = Uri.parse(connection.getURL().toString()); assertEquals("android", uri.getQueryParameter("sdk")); assertEquals("json", uri.getQueryParameter("format")); }
@Test public void testBuildsClientTokenIfNeeded() throws Exception { GraphRequest requestMe = new GraphRequest(null, "TourEiffel"); HttpURLConnection connection = GraphRequest.toHttpConnection(requestMe); assertTrue(connection != null); Uri uri = Uri.parse(connection.getURL().toString()); String accessToken = uri.getQueryParameter("access_token"); assertNotNull(accessToken); assertTrue(accessToken.contains(FacebookSdk.getApplicationId())); assertTrue(accessToken.contains(FacebookSdk.getClientToken())); } }