本文整理汇总了Java中android.net.Uri.getQueryParameterNames方法的典型用法代码示例。如果您正苦于以下问题:Java Uri.getQueryParameterNames方法的具体用法?Java Uri.getQueryParameterNames怎么用?Java Uri.getQueryParameterNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.Uri
的用法示例。
在下文中一共展示了Uri.getQueryParameterNames方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildNewUri
import android.net.Uri; //导入方法依赖的package包/类
private Uri buildNewUri(Uri uri, String targetAuthority) {
Builder b = new Builder();
b.scheme(uri.getScheme());
b.authority(targetAuthority);
b.path(uri.getPath());
if (VERSION.SDK_INT >= 11) {
Set<String> names = uri.getQueryParameterNames();
if (names != null && names.size() > 0) {
for (String name : names) {
if (!TextUtils.equals(name, ApkConstant.EXTRA_TARGET_AUTHORITY)) {
b.appendQueryParameter(name, uri.getQueryParameter(name));
}
}
}
} else {
b.query(uri.getQuery());
}
b.fragment(uri.getFragment());
return b.build();
}
示例2: parseRealIntent
import android.net.Uri; //导入方法依赖的package包/类
private void parseRealIntent(){
String tempUriStr = realIntent.getDataString();
if(tempUriStr != null && tempUriStr.startsWith("mqqapi://")) { //qq的参数是base64加密的
Uri tempUri = realIntent.getData();
Set<String> tempSet = tempUri.getQueryParameterNames();
tempUriStr = tempUriStr + "\n" + getString(R.string.string_decoded) + "\n";
for (String tempStr:tempSet){
String tempStrGet = tempUri.getQueryParameter(tempStr);
String tempBase64Decoded = "";
try{
tempBase64Decoded = new String(Base64.decode(tempStrGet.replaceAll(" ", "+").getBytes(),Base64.DEFAULT));
}catch (Exception e){
tempBase64Decoded = tempStrGet;
}
tempUriStr = tempUriStr + tempStr + ":" + tempBase64Decoded + "\n";
}
}
String tempBundle = utils.toString(utils.goThroughBundleAsString(realIntent.getExtras()));
textView.setText(String.valueOf(tempUriStr)+"\n"+tempBundle);
}
示例3: buildNewUri
import android.net.Uri; //导入方法依赖的package包/类
private Uri buildNewUri(Uri uri, String targetAuthority) {
Uri.Builder b = new Builder();
b.scheme(uri.getScheme());
b.authority(targetAuthority);
b.path(uri.getPath());
if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
Set<String> names = uri.getQueryParameterNames();
if (names != null && names.size() > 0) {
for (String name : names) {
if (!TextUtils.equals(name, Env.EXTRA_TARGET_AUTHORITY)) {
b.appendQueryParameter(name, uri.getQueryParameter(name));
}
}
}
} else {
b.query(uri.getQuery());
}
b.fragment(uri.getFragment());
return b.build();
}
示例4: doSetCode
import android.net.Uri; //导入方法依赖的package包/类
/**
* STEP.2
* Mastodon OAuth Authorization Codeを設定保存
* @param uri インスタンスURL
*/
private void doSetCode(@NonNull Uri uri) {
Log.d("doSetCode", uri.toString());
Set<String> queryNames = uri.getQueryParameterNames();
if( queryNames.contains("error") ) {
Snackbar.make(contentView, "アプリケーションの利用が承認されていません。", Snackbar.LENGTH_LONG).show();
rollbackOAuth();
return;
}
String code = uri.getQueryParameter("code");
String baseUrl = manager.getCurrentMastodon();
if (baseUrl.isEmpty()) {
Snackbar.make(contentView, "マストドンアカウント情報がありません。", Snackbar.LENGTH_LONG).show();
rollbackOAuth();
return;
}
currentMastodonPrefs.setCode(code);
currentMastodonPrefs.save();
}
示例5: parseQueryParams
import android.net.Uri; //导入方法依赖的package包/类
private Map<String, String> parseQueryParams(final String queryStr) {
final String urlStr = "http://server?" + queryStr;
final Uri uri = Uri.parse(urlStr);
final Set<String> queryParameterNames = uri.getQueryParameterNames();
final Map<String, String> queryParams = new HashMap<String, String>(queryParameterNames.size());
for (String paramName : queryParameterNames) {
queryParams.put(paramName, uri.getQueryParameter(paramName));
}
return queryParams;
}
示例6: onQueryByText
import android.net.Uri; //导入方法依赖的package包/类
@Override
public void onQueryByText(String text) {
final String searchParamKey =
Kolibri.getInstance(kolibriWebView.getContext()).getRuntime().getComponent("search")
.getSettings().getString("search-param");
String url = kolibriWebView.getUrl();
Uri uri = Uri.parse(url);
if (!"".equals(text)) {
Uri.Builder builder = uri.buildUpon();
builder.clearQuery();
if (uri.getQueryParameterNames().size() <= 0
|| uri.getQueryParameter(searchParamKey) == null) {
builder.appendQueryParameter(searchParamKey, text);
} else {
for (String key : uri.getQueryParameterNames()) {
if (searchParamKey.equals(key)) {
builder.appendQueryParameter(searchParamKey, text);
} else {
builder.appendQueryParameter(key, uri.getQueryParameter(key));
}
}
}
uri = builder.build();
}
kolibriWebView.loadUrl(uri.toString());
}
示例7: getQueryParams
import android.net.Uri; //导入方法依赖的package包/类
private static Map<String, String> getQueryParams(Request<?> request) {
Uri uri = Uri.parse(request.getUrl());
Map<String, String> result = new HashMap<>();
for (String key : uri.getQueryParameterNames()) {
for (String value : uri.getQueryParameters(key)) {
if (result.containsKey(key)) {
result.put(key, result.get(key) + ";" + value);
} else {
result.put(key, value);
}
}
}
return result;
}
示例8: onBrowserSwitchResult
import android.net.Uri; //导入方法依赖的package包/类
@Override
public void onBrowserSwitchResult(int requestCode, BrowserSwitchResult result, Uri returnUri) {
String error = null;
String payload = null;
if (result == BrowserSwitchResult.OK) {
if (returnUri == null || !returnUri.getScheme().equals(getReturnUrlScheme()) ||
!returnUri.getHost().equals(POPUP_BRIDGE_URL_HOST)) {
return;
}
JSONObject json = new JSONObject();
JSONObject queryItems = new JSONObject();
Set<String> queryParams = returnUri.getQueryParameterNames();
if (queryParams != null && !queryParams.isEmpty()) {
for (String queryParam : queryParams) {
try {
queryItems.put(queryParam, returnUri.getQueryParameter(queryParam));
} catch (JSONException e) {
error = "new Error('Failed to parse query items from return URL. " +
e.getLocalizedMessage() + "')";
}
}
}
try {
json.put("path", returnUri.getPath());
json.put("queryItems", queryItems);
} catch (JSONException ignored) {}
payload = json.toString();
} else if (result == BrowserSwitchResult.ERROR) {
error = "new Error('" + result.getErrorMessage() + "')";
}
mWebView.evaluateJavascript(String.format("window.popupBridge.onComplete(%s, %s);", error,
payload), null);
}
示例9: getBlobBuilder
import android.net.Uri; //导入方法依赖的package包/类
@NonNull static Uri getBlobBuilder(@NonNull Uri uri) {
boolean isSvg = "svg".equalsIgnoreCase(MimeTypeMap.getFileExtensionFromUrl(uri.toString()));
List<String> segments = uri.getPathSegments();
if (isSvg) {
Uri svgBlob = Uri.parse(uri.toString().replace("blob/", ""));
return svgBlob.buildUpon().authority(RAW_AUTHORITY).build();
}
Uri.Builder urlBuilder = new Uri.Builder();
String owner = segments.get(0);
String repo = segments.get(1);
String branch = segments.get(3);
urlBuilder.scheme("https")
.authority(API_AUTHORITY)
.appendPath("repos")
.appendPath(owner)
.appendPath(repo)
.appendPath("contents");
for (int i = 4; i < segments.size(); i++) {
urlBuilder.appendPath(segments.get(i));
}
if (uri.getQueryParameterNames() != null) {
for (String query : uri.getQueryParameterNames()) {
urlBuilder.appendQueryParameter(query, uri.getQueryParameter(query));
}
}
if (uri.getEncodedFragment() != null) {
urlBuilder.encodedFragment(uri.getEncodedFragment());
}
urlBuilder.appendQueryParameter("ref", branch);
return urlBuilder.build();
}
示例10: isMatched
import android.net.Uri; //导入方法依赖的package包/类
public boolean isMatched(String url)
{
if(TextUtils.isEmpty(url)) return false;
Uri uri = Uri.parse(url);
String host = uri.getHost();
if(!TextUtils.isEmpty(host) && TextUtils.equals(this.host, host))
{
if(paramsFilter.isEmpty())
{
return true;
}
else
{
Set<String> queryKeySet = uri.getQueryParameterNames();
if(queryKeySet.isEmpty()) return false;
boolean isAllParamsMatched = true;
for(String paramKey : paramsFilter.keySet())
{
isAllParamsMatched = isAllParamsMatched
&& queryKeySet.contains(paramKey)
&& TextUtils.equals(paramsFilter.get(paramKey), uri.getQueryParameter(paramKey));
}
return isAllParamsMatched;
}
}
return false;
}
示例11: parseExtras
import android.net.Uri; //导入方法依赖的package包/类
public Bundle parseExtras(String url)
{
if(TextUtils.isEmpty(url)) return null;
Bundle extras = new Bundle();
Uri uri = Uri.parse(url);
extras.putParcelable(DPROUTER_BUNDLE_KEY_FULL_URI, uri);
extras.putString(DPROUTER_BUNDLE_KEY_HOST, uri.getHost());
String path = uri.getPath();
if(!TextUtils.isEmpty(path))
{
if(path.startsWith("/"))
{
path = path.substring(1);
}
extras.putString(DPROUTER_BUNDLE_KEY_PATH, path);
}
//Parse all the query items in the url
Set<String> queryKeySet = uri.getQueryParameterNames();
if(!queryKeySet.isEmpty())
{
for(String key : queryKeySet)
{
extras.putString(key, uri.getQueryParameter(key));
}
}
return extras;
}
示例12: from
import android.net.Uri; //导入方法依赖的package包/类
public static UrlBuilder from(Uri uri) {
UrlQuery query = new UrlQuery();
Set<String> queryKeys = uri.getQueryParameterNames();
for (String queryKey : queryKeys) {
List<String> queryValues = uri.getQueryParameters(queryKey);
for (String queryValue : queryValues) {
query.append(queryKey, queryValue);
}
}
return from(uri.getScheme(), uri.getHost(), uri.getPort(), UrlPath.parse(uri.getPath()), query, uri.getFragment());
}
示例13: onPageStarted
import android.net.Uri; //导入方法依赖的package包/类
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
final Uri uri = Uri.parse(url);
final String value = uri.getQueryParameter(queryParam);
if (value != null) {
Intent resultIntent = new Intent();
for (String name : uri.getQueryParameterNames()) {
resultIntent.putExtra(name, uri.getQueryParameter(name));
}
setResult(Activity.RESULT_OK, resultIntent);
finish();
}
super.onPageStarted(view, url, favicon);
}
示例14: handleIntent
import android.net.Uri; //导入方法依赖的package包/类
private void handleIntent(Intent intent) {
if (intent == null) {
return;
}
final Uri data = intent.getData();
final String appPackageName;
if (data != null) {
appPackageName = data.getHost();
final Set<String> params = data.getQueryParameterNames();
if (params.contains(SEARCH_PARAM)) {
mInputTypeView.setSelection(SEARCH_INDEX);
mUriInput.setText(data.getQueryParameter(SEARCH_PARAM));
} else if (params.contains(MEDIA_ID_PARAM)) {
mInputTypeView.setSelection(MEDIA_ID_INDEX);
mUriInput.setText(data.getQueryParameter(MEDIA_ID_PARAM));
} else if (params.contains(URI_PARAM)) {
mInputTypeView.setSelection(URI_INDEX);
mUriInput.setText(data.getQueryParameter(URI_PARAM));
}
} else if (intent.hasExtra(PACKAGE_NAME_EXTRA)) {
appPackageName = intent.getStringExtra(PACKAGE_NAME_EXTRA);
} else {
appPackageName = null;
}
// Create app details from URI, if one was present.
if (appPackageName != null) {
if (mMediaAppDetails == null || !appPackageName.equals(CURRENT_PACKAGE)) {
connectToMediaBrowserPackage(appPackageName);
}
}
final Bundle extras = intent.getExtras();
if (extras != null) {
// Pull data out of the extras, if they're there.
if (extras.containsKey(SEARCH_EXTRA)) {
mInputTypeView.setSelection(SEARCH_INDEX);
mUriInput.setText(extras.getString(SEARCH_EXTRA));
} else if (extras.containsKey(MEDIA_ID_EXTRA)) {
mInputTypeView.setSelection(MEDIA_ID_INDEX);
mUriInput.setText(extras.getString(MEDIA_ID_EXTRA));
} else if (extras.containsKey(URI_EXTRA)) {
mInputTypeView.setSelection(URI_INDEX);
mUriInput.setText(extras.getString(URI_EXTRA));
}
// It's also possible we're here from LaunchActivity, which did all this work for us.
if (extras.containsKey(APP_DETAILS_EXTRA)) {
mMediaAppDetails = extras.getParcelable(APP_DETAILS_EXTRA);
}
}
}