當前位置: 首頁>>代碼示例>>Java>>正文


Java Uri.getQueryParameterNames方法代碼示例

本文整理匯總了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();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:21,代碼來源:AbstractContentProviderStub.java

示例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);
}
 
開發者ID:CwithW,項目名稱:PretendSharing_Xposed,代碼行數:21,代碼來源:MessageExtractActivity.java

示例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();
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:22,代碼來源:AbstractContentProviderStub.java

示例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();
}
 
開發者ID:npdess,項目名稱:mining,代碼行數:27,代碼來源:LoginMastodonActivity.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:ConnectionQueueTests.java

示例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());
}
 
開發者ID:azmedien,項目名稱:kolibri-android,代碼行數:33,代碼來源:SearchWebviewCoordinator.java

示例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;
}
 
開發者ID:rakutentech,項目名稱:android-perftracking,代碼行數:15,代碼來源:BaseRequestTest.java

示例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);
}
 
開發者ID:braintree,項目名稱:popup-bridge-android,代碼行數:40,代碼來源:PopupBridge.java

示例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();
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:32,代碼來源:LinkParserHelper.java

示例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;
}
 
開發者ID:kfrozen,項目名稱:DeeplinkRouter,代碼行數:36,代碼來源:Mapping.java

示例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;
}
 
開發者ID:kfrozen,項目名稱:DeeplinkRouter,代碼行數:39,代碼來源:Mapping.java

示例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());
}
 
開發者ID:ImKarl,項目名稱:UrlBuilder,代碼行數:12,代碼來源:UrlBuilder.java

示例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);
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:15,代碼來源:WebLoginActivity.java

示例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);
        }
    }
}
 
開發者ID:googlesamples,項目名稱:android-media-controller,代碼行數:55,代碼來源:MediaAppControllerActivity.java


注:本文中的android.net.Uri.getQueryParameterNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。