本文整理汇总了Java中android.net.Uri.getEncodedQuery方法的典型用法代码示例。如果您正苦于以下问题:Java Uri.getEncodedQuery方法的具体用法?Java Uri.getEncodedQuery怎么用?Java Uri.getEncodedQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.Uri
的用法示例。
在下文中一共展示了Uri.getEncodedQuery方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: a
import android.net.Uri; //导入方法依赖的package包/类
public static MLinkResult a(Uri uri, Uri uri2) {
if (uri2 == null) {
return new MLinkResult();
}
String scheme = uri2.getScheme();
String host = uri2.getHost();
int port = uri2.getPort();
String encodedPath = uri2.getEncodedPath();
String encodedQuery = uri2.getEncodedQuery();
String scheme2 = uri.getScheme();
String host2 = uri.getHost();
int port2 = uri.getPort();
String encodedPath2 = uri.getEncodedPath();
String encodedQuery2 = uri.getEncodedQuery();
if (n.a(scheme, scheme2) && n.a(host, host2) && port == port2) {
return a(encodedPath, encodedPath2, a(encodedQuery2, encodedQuery));
}
return new MLinkResult();
}
示例2: encodedQueryParameters
import android.net.Uri; //导入方法依赖的package包/类
/**
* Returns a map of the unique names of all query parameters. Iterating
* over the set will return the names in order of their first occurrence.
*
* @param uri The URI to transform.
* @return A map of decoded names.
*/
@NonNull
private static Map<String, String> encodedQueryParameters(@NonNull final Uri uri) {
final HashMap<String, String> map = new HashMap<>();
final String query = uri.getEncodedQuery();
if (query != null) {
String[] ands = query.split("&");
for (String and : ands) {
int splitIndex = and.indexOf("=");
if (splitIndex != -1) {
map.put(and.substring(0, splitIndex), and.substring(splitIndex + 1));
} else {
Log.w("ParametersParseError", "query: " + query);
}
}
}
return map;
}
示例3: getQueryParameter
import android.net.Uri; //导入方法依赖的package包/类
/**
* Return a map of argument->value from a query in a URI
*
* @param uri The URI
*/
private Map<String, String> getQueryParameter(Uri uri) {
if (uri.isOpaque()) {
return Collections.emptyMap();
}
String query = uri.getEncodedQuery();
if (query == null) {
return Collections.emptyMap();
}
Map<String, String> parameters = new LinkedHashMap<>();
int start = 0;
do {
int next = query.indexOf('&', start);
int end = (next == -1) ? query.length() : next;
int separator = query.indexOf('=', start);
if (separator > end || separator == -1) {
separator = end;
}
String name = query.substring(start, separator);
String value;
if (separator < end)
value = query.substring(separator + 1, end);
else
value = "";
parameters.put(Uri.decode(name), Uri.decode(value));
// Move start to end of name.
start = end + 1;
} while (start < query.length());
return Collections.unmodifiableMap(parameters);
}
示例4: getQueryParameterNames
import android.net.Uri; //导入方法依赖的package包/类
public static Set<String> getQueryParameterNames(Uri uri) {
String query = uri.getEncodedQuery();
if (query == null) {
return Collections.emptySet();
}
Set<String> names = new LinkedHashSet<String>();
int start = 0;
do {
int next = query.indexOf('&', start);
int end = (next == -1) ? query.length() : next;
int separator = query.indexOf('=', start);
if (separator > end || separator == -1) {
separator = end;
}
String name = query.substring(start, separator);
try {
names.add(URLDecoder.decode(name, "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
start = end + 1;
} while (start < query.length());
return Collections.unmodifiableSet(names);
}
示例5: appendQuery
import android.net.Uri; //导入方法依赖的package包/类
private static Uri.Builder appendQuery(Uri.Builder builder, String query) {
Uri current = builder.build();
String oldQuery = current.getEncodedQuery();
if (oldQuery != null && oldQuery.length() > 0) {
query = oldQuery + "&" + query;
}
return builder.encodedQuery(query);
}