本文整理了Java中android.net.Uri.getQueryParameter()
方法的一些代码示例,展示了Uri.getQueryParameter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Uri.getQueryParameter()
方法的具体详情如下:
包路径:android.net.Uri
类名称:Uri
方法名:getQueryParameter
[英]Searches the query string for the first value with the given key.
Warning: Prior to Ice Cream Sandwich, this decoded the '+' character as '+' rather than ' '.
[中]使用给定的键在查询字符串中搜索第一个值。
警告:在吃冰淇淋三明治之前,这会将“+”字符解码为“+”而不是“”。
代码示例来源:origin: k9mail/k-9
@Override
public String getType(Uri uri) {
return uri.getQueryParameter("mime_type");
}
代码示例来源:origin: robolectric/robolectric
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;
}
}
代码示例来源:origin: TommyLemon/APIJSON
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));
}
代码示例来源:origin: k9mail/k-9
@Override
public String getType(Uri uri) {
return uri.getQueryParameter("mime_type");
}
代码示例来源:origin: TommyLemon/Android-ZBLibrary
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));
}
代码示例来源:origin: stackoverflow.com
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
}
代码示例来源:origin: yipianfengye/android-zxingLibrary
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));
}
代码示例来源:origin: stackoverflow.com
Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri uri = intent.getData();
String valueOne = uri.getQueryParameter("keyOne");
String valueTwo = uri.getQueryParameter("keyTwo");
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
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));
}
代码示例来源:origin: stackoverflow.com
// query code
Uri queryUri = Uri.parse("content://what/ever/items");
queryUri = queryUri.buildUpon().appendQueryParameter("limit", "5").build();
// in ContentProvider
String limit = queryUri.getQueryParameter("limit");
代码示例来源:origin: stackoverflow.com
/**
* 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");
}
代码示例来源:origin: grandcentrix/tray
/**
* 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);
}
代码示例来源:origin: k9mail/k-9
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();
}
代码示例来源:origin: hidroh/materialistic
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);
}
}
代码示例来源:origin: zwwill/yanxuan-weex-demo
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;
}
代码示例来源:origin: facebook/facebook-android-sdk
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;
}
代码示例来源:origin: robolectric/robolectric
@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");
}
}
代码示例来源:origin: google/ExoPlayer
@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;
}
}
代码示例来源:origin: facebook/facebook-android-sdk
@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"));
}
代码示例来源:origin: facebook/facebook-android-sdk
@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()));
}
}
内容来源于网络,如有侵权,请联系作者删除!