List of usage examples for android.net Uri getQuery
@Nullable public abstract String getQuery();
From source file:com.just.agentweb.AgentWebUtils.java
@TargetApi(19) static String getFileAbsolutePath(Activity context, Uri fileUri) { if (context == null || fileUri == null) { return null; }//from w w w. j av a 2 s .c o m LogUtils.i(TAG, "getAuthority:" + fileUri.getAuthority() + " getHost:" + fileUri.getHost() + " getPath:" + fileUri.getPath() + " getScheme:" + fileUri.getScheme() + " query:" + fileUri.getQuery()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, fileUri)) { if (isExternalStorageDocument(fileUri)) { String docId = DocumentsContract.getDocumentId(fileUri); String[] split = docId.split(":"); String type = split[0]; if ("primary".equalsIgnoreCase(type)) { return Environment.getExternalStorageDirectory() + "/" + split[1]; } } else if (isDownloadsDocument(fileUri)) { String id = DocumentsContract.getDocumentId(fileUri); Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); return getDataColumn(context, contentUri, null, null); } else if (isMediaDocument(fileUri)) { String docId = DocumentsContract.getDocumentId(fileUri); String[] split = docId.split(":"); String type = split[0]; Uri contentUri = null; if ("image".equals(type)) { contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; } else if ("video".equals(type)) { contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; } else if ("audio".equals(type)) { contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; } String selection = MediaStore.Images.Media._ID + "=?"; String[] selectionArgs = new String[] { split[1] }; return getDataColumn(context, contentUri, selection, selectionArgs); } else { } } // MediaStore (and general) else if (fileUri.getAuthority().equalsIgnoreCase(context.getPackageName() + ".AgentWebFileProvider")) { String path = fileUri.getPath(); int index = path.lastIndexOf("/"); return getAgentWebFilePath(context) + File.separator + path.substring(index + 1, path.length()); } else if ("content".equalsIgnoreCase(fileUri.getScheme())) { // Return the remote address if (isGooglePhotosUri(fileUri)) { return fileUri.getLastPathSegment(); } return getDataColumn(context, fileUri, null, null); } // File else if ("file".equalsIgnoreCase(fileUri.getScheme())) { return fileUri.getPath(); } return null; }
From source file:org.apache.cordova.test.junit.CordovaResourceApiTest.java
protected void setUp() throws Exception { super.setUp(); activity = this.getActivity(); cordovaWebView = activity.cordovaWebView; resourceApi = cordovaWebView.getResourceApi(); resourceApi.setThreadCheckingEnabled(false); cordovaWebView.pluginManager/* www.j a v a2 s. c o m*/ .addService(new PluginEntry("CordovaResourceApiTestPlugin1", new CordovaPlugin() { @Override public Uri remapUri(Uri uri) { if (uri.getQuery() != null && uri.getQuery().contains("pluginRewrite")) { return cordovaWebView.getResourceApi() .remapUri(Uri.parse("data:text/plain;charset=utf-8,pass")); } return null; } public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { synchronized (CordovaResourceApiTest.this) { execPayload = args.getString(0); execStatus = args.getInt(1); CordovaResourceApiTest.this.notify(); } return true; } })); }
From source file:org.apache.cordova.test.CordovaResourceApiTest.java
protected void setUp() throws Exception { super.setUp(); setUpWithStartUrl(null);//from w ww. ja v a 2 s . com resourceApi = cordovaWebView.getResourceApi(); resourceApi.setThreadCheckingEnabled(false); cordovaWebView.getPluginManager() .addService(new PluginEntry("CordovaResourceApiTestPlugin1", new CordovaPlugin() { @Override public Uri remapUri(Uri uri) { if (uri.getQuery() != null && uri.getQuery().contains("pluginRewrite")) { return cordovaWebView.getResourceApi() .remapUri(Uri.parse("data:text/plain;charset=utf-8,pass")); } if (uri.getQuery() != null && uri.getQuery().contains("pluginUri")) { return toPluginUri(uri); } return null; } @Override public OpenForReadResult handleOpenForRead(Uri uri) throws IOException { Uri orig = fromPluginUri(uri); ByteArrayInputStream retStream = new ByteArrayInputStream( orig.toString().getBytes(StandardCharsets.UTF_8)); return new OpenForReadResult(uri, retStream, "text/plain", retStream.available(), null); } @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { synchronized (CordovaResourceApiTest.this) { execPayload = args.getString(0); execStatus = args.getInt(1); CordovaResourceApiTest.this.notify(); } return true; } })); }
From source file:com.polyvi.xface.view.XWebViewClient.java
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { try {//from www . j a v a2 s .c o m // ?exec()?. if (XNativeToJsMessageQueue.ENABLE_LOCATION_CHANGE_EXEC_MODE && url.startsWith(XFACE_EXEC_URL_PREFIX)) { handleExecUrl(url); } XWhiteList whiteList = mWebAppView.getOwnerApp().getAppInfo().getWhiteList(); if (url.startsWith("tel") && !XConfiguration.getInstance().isTelLinkEnabled()) { return true; } // TODO:??phonegap?url???? else if (url.startsWith(XConstant.FILE_SCHEME) || url.startsWith("data:") || ((url.startsWith(XConstant.HTTP_SCHEME) || url.startsWith(XConstant.HTTPS_SCHEME)) && (null != whiteList && whiteList.isUrlWhiteListed(url)))) { /** * I9003??url? url??? */ return handleUrl(url); } else if (url.startsWith(XConstant.SCHEME_SMS)) { Intent intent = new Intent(Intent.ACTION_VIEW); // ?? String address = null; int parmIndex = url.indexOf('?'); if (-1 == parmIndex) { address = url.substring(XConstant.SCHEME_SMS.length()); } else { address = url.substring(XConstant.SCHEME_SMS.length(), parmIndex); Uri uri = Uri.parse(url); String query = uri.getQuery(); if (null != query) { if (query.startsWith(SMS_BODY)) { intent.putExtra("sms_body", query.substring(SMS_BODY.length())); } } } intent.setData(Uri.parse(XConstant.SCHEME_SMS + address)); intent.putExtra("address", address); intent.setType("vnd.android-dir/mms-sms"); mSystemContext.getContext().startActivity(intent); return true; } else { // ????? return startSysApplication(url); } } catch (ActivityNotFoundException e) { XLog.e(CLASS_NAME, e.toString()); } return false; }
From source file:com.scm.reader.resultPage.webview.ShortcutWebViewClient.java
public boolean shouldOverrideUrlLoading(WebView view, Uri uri) { if ("copy".equals(uri.getScheme())) { overrideCopy(view.getUrl());/*from ww w.j a v a 2 s . c om*/ return true; } else if ("sms".equals(uri.getScheme())) { overrideSMS(uri.getQuery()); return true; } else if ("mailto".equals(uri.getScheme())) { overrideEmail(uri); return true; } else if ("tel".equals(uri.getScheme())) { overrideTel(uri); return true; } return false; }
From source file:com.silverpop.engage.deeplinking.EngageDeepLinkManager.java
private Map<String, String> parseQueryParameters(Uri deeplink) { if (deeplink != null) { Map<String, String> params = new HashMap<String, String>(); String queryString = deeplink.getQuery(); if (queryString != null) { String[] queryComponents = queryString.split("&"); if (queryComponents != null && queryComponents.length > 0) { for (String queryComponent : queryComponents) { String[] queryParts = queryComponent.split("="); if (queryParts != null && queryParts.length == 2) { params.put(queryParts[0], queryParts[1]); }//www .ja v a 2 s. c o m } } } return params; } else { return null; } }
From source file:com.breadwallet.tools.security.RequestHandler.java
public static void processBitIdResponse(final Activity app) { final byte[] phrase; final byte[] nulTermPhrase; final byte[] seed; if (app == null) { Log.e(TAG, "processBitIdResponse: app is null"); return;// w ww . j ava 2 s. c om } if (_bitUri == null) { Log.e(TAG, "processBitIdResponse: _bitUri is null"); return; } final Uri uri = Uri.parse(_bitUri); try { phrase = KeyStoreManager.getKeyStorePhrase(app, REQUEST_PHRASE_BITID); } catch (BRKeystoreErrorException e) { Log.e(TAG, "processBitIdResponse: failed to getKeyStorePhrase: " + e.getCause().getMessage()); return; } nulTermPhrase = TypesConverter.getNullTerminatedPhrase(phrase); seed = BRWalletManager.getSeedFromPhrase(nulTermPhrase); if (seed == null) { Log.e(TAG, "processBitIdResponse: seed is null!"); return; } //run the callback new Thread(new Runnable() { @Override public void run() { try { if (_strToSign == null) { //meaning it's a link handling String nonce = null; String scheme = "https"; String query = uri.getQuery(); if (query == null) { Log.e(TAG, "run: Malformed URI"); return; } String u = uri.getQueryParameter("u"); if (u != null && u.equalsIgnoreCase("1")) { scheme = "http"; } String x = uri.getQueryParameter("x"); if (Utils.isNullOrEmpty(x)) { nonce = newNonce(app, uri.getHost() + uri.getPath()); // we are generating our own nonce } else { nonce = x; // service is providing a nonce } String callbackUrl = String.format("%s://%s%s", scheme, uri.getHost(), uri.getPath()); // build a payload consisting of the signature, address and signed uri String uriWithNonce = String.format("bitid://%s%s?x=%s", uri.getHost(), uri.getPath(), nonce); final byte[] key = BRBIP32Sequence.getInstance().bip32BitIDKey(seed, _index, callbackUrl); if (key == null) { Log.d(TAG, "processBitIdResponse: key is null!"); return; } // Log.e(TAG, "run: uriWithNonce: " + uriWithNonce); final String sig = BRBitId.signMessage(_strToSign == null ? uriWithNonce : _strToSign, new BRKey(key)); final String address = new BRKey(key).address(); JSONObject postJson = new JSONObject(); try { postJson.put("address", address); postJson.put("signature", sig); if (_strToSign == null) postJson.put("uri", uriWithNonce); } catch (JSONException e) { e.printStackTrace(); } RequestBody requestBody = RequestBody.create(null, postJson.toString()); Request request = new Request.Builder().url(callbackUrl + "?x=" + nonce).post(requestBody) .header("Content-Type", "application/json").build(); Response res = APIClient.getInstance(app).sendRequest(request, true, 0); Log.e(TAG, "processBitIdResponse: res.code: " + res.code()); Log.e(TAG, "processBitIdResponse: res.code: " + res.message()); try { Log.e(TAG, "processBitIdResponse: body: " + res.body().string()); } catch (IOException e) { e.printStackTrace(); } } else { //meaning its the wallet plugin, glidera auth String biUri = uri.getHost() == null ? uri.toString() : uri.getHost(); final byte[] key = BRBIP32Sequence.getInstance().bip32BitIDKey(seed, _index, biUri); if (key == null) { Log.d(TAG, "processBitIdResponse: key is null!"); return; } // Log.e(TAG, "run: uriWithNonce: " + uriWithNonce); final String sig = BRBitId.signMessage(_strToSign, new BRKey(key)); final String address = new BRKey(key).address(); JSONObject postJson = new JSONObject(); try { postJson.put("address", address); postJson.put("signature", sig); } catch (JSONException e) { e.printStackTrace(); } WalletPlugin.handleBitId(postJson); } } finally { //release everything _bitUri = null; _strToSign = null; _bitCallback = null; _authString = null; _index = 0; if (phrase != null) Arrays.fill(phrase, (byte) 0); if (nulTermPhrase != null) Arrays.fill(nulTermPhrase, (byte) 0); if (seed != null) Arrays.fill(seed, (byte) 0); } } }).start(); }
From source file:com.androidquery.simplefeed.fragments.NotificationFragment.java
private String getAliasId(String link, Uri uri) { String query = uri.getQuery(); if (query == null || query.length() == 0) { String[] splits = link.split("/"); if (splits.length < 2) return null; if (splits[splits.length - 2].equalsIgnoreCase("www.facebook.com")) { return splits[splits.length - 1]; }/* w w w .j a va2s.c om*/ } return null; }
From source file:com.benefit.buy.library.http.query.callback.AbstractAjaxCallback.java
private static Map<String, Object> extractParams(Uri uri) { Map<String, Object> params = new HashMap<String, Object>(); String[] pairs = uri.getQuery().split("&"); for (String pair : pairs) { String[] split = pair.split("="); if (split.length >= 2) { params.put(split[0], split[1]); } else if (split.length == 1) { params.put(split[0], ""); }/*from w w w . j av a 2 s . c o m*/ } return params; }
From source file:io.ionic.links.IonicDeeplink.java
public void handleIntent(Intent intent) { final String intentString = intent.getDataString(); // read intent String action = intent.getAction(); Uri url = intent.getData(); JSONObject bundleData = this._bundleToJson(intent.getExtras()); Log.d(TAG, "Got a new intent: " + intentString + " " + intent.getScheme() + " " + action + " " + url); // if app was not launched by the url - ignore if (!Intent.ACTION_VIEW.equals(action) || url == null) { return;/*from w ww . ja v a 2 s . co m*/ } // store message and try to consume it try { lastEvent = new JSONObject(); lastEvent.put("url", url.toString()); lastEvent.put("path", url.getPath()); lastEvent.put("queryString", url.getQuery()); lastEvent.put("scheme", url.getScheme()); lastEvent.put("host", url.getHost()); lastEvent.put("fragment", url.getFragment()); lastEvent.put("extra", bundleData); consumeEvents(); } catch (JSONException ex) { Log.e(TAG, "Unable to process URL scheme deeplink", ex); } }