Java Code Examples for android.net.Uri#Builder
The following examples show how to use
android.net.Uri#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirebaseDynamicLinksImpl.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
public static Uri createDynamicLink(Bundle builderParameters) { verifyDomainUriPrefix(builderParameters); Uri longLink = builderParameters.getParcelable(Builder.KEY_DYNAMIC_LINK); if (longLink == null) { // Long link was not supplied, build the Dynamic Link from Dynamic Link parameters. Uri.Builder builder = new Uri.Builder(); Uri uri = Uri.parse(builderParameters.getString(Builder.KEY_DOMAIN_URI_PREFIX)); builder.scheme(uri.getScheme()); builder.authority(uri.getAuthority()); builder.path(uri.getPath()); Bundle fdlParameters = builderParameters.getBundle(Builder.KEY_DYNAMIC_LINK_PARAMETERS); for (String key : fdlParameters.keySet()) { Object value = fdlParameters.get(key); if (value != null) { builder.appendQueryParameter(key, value.toString()); } } longLink = builder.build(); } return longLink; }
Example 2
Source File: Select.java From CPOrm with MIT License | 6 votes |
/** * Packages this select into a {@link za.co.cporm.model.util.ContentResolverValues} package, this will contain all of the required arguments to run this query on * a content resolver, it is used internally by all of the as* methods. * * @return The {@link za.co.cporm.model.util.ContentResolverValues} containing the arguments needed by the content resolver query method */ public ContentResolverValues asContentResolverValue(Context context) { if (context == null) throw new IllegalArgumentException("Attempt to query with a null context"); TableDetails tableDetails = CPOrm.findTableDetails(context, dataObjectClass); QueryBuilder where = buildWhereClause(context, ManifestHelper.getMappingFactory(context)); QueryBuilder sort = buildSort(); Uri.Builder itemUri = UriMatcherHelper.generateItemUri(context, tableDetails); if (offset != null) itemUri.appendQueryParameter(CPOrmContentProvider.PARAMETER_OFFSET, offset.toString()); if (limit != null) itemUri.appendQueryParameter(CPOrmContentProvider.PARAMETER_LIMIT, limit.toString()); if(distinct) itemUri.appendQueryParameter("DISTINCT", Boolean.TRUE.toString()); if(!TextUtils.isEmpty(groupBy)) { itemUri.appendQueryParameter("GROUP_BY", groupBy); if (!TextUtils.isEmpty(having)) itemUri.appendQueryParameter("HAVING", having); } return new ContentResolverValues(tableDetails, itemUri.build(), getProjection(tableDetails), where.getQueryString(), where.getQueryArgsAsArray(), sort.getQueryString()); }
Example 3
Source File: Settings.java From EhViewer with Apache License 2.0 | 6 votes |
@Nullable public static UniFile getDownloadLocation() { UniFile dir = null; try { Uri.Builder builder = new Uri.Builder(); builder.scheme(getString(KEY_DOWNLOAD_SAVE_SCHEME, null)); builder.encodedAuthority(getString(KEY_DOWNLOAD_SAVE_AUTHORITY, null)); builder.encodedPath(getString(KEY_DOWNLOAD_SAVE_PATH, null)); builder.encodedQuery(getString(KEY_DOWNLOAD_SAVE_QUERY, null)); builder.encodedFragment(getString(KEY_DOWNLOAD_SAVE_FRAGMENT, null)); dir = UniFile.fromUri(sContext, builder.build()); } catch (Throwable e) { ExceptionUtils.throwIfFatal(e); // Ignore } return dir != null ? dir : UniFile.fromFile(AppConfig.getDefaultDownloadDir()); }
Example 4
Source File: Settings.java From Nimingban with Apache License 2.0 | 6 votes |
@Nullable public static UniFile getImageSaveLocation() { UniFile dir = null; try { Uri.Builder builder = new Uri.Builder(); builder.scheme(getString(KEY_IMAGE_SAVE_SCHEME, null)); builder.encodedAuthority(getString(KEY_IMAGE_SAVE_AUTHORITY, null)); builder.encodedPath(getString(KEY_IMAGE_SAVE_PATH, null)); builder.encodedQuery(getString(KEY_IMAGE_SAVE_QUERY, null)); builder.encodedFragment(getString(KEY_IMAGE_SAVE_FRAGMENT, null)); dir = UniFile.fromUri(sContext, builder.build()); } catch (Exception e) { e.printStackTrace(); } return dir != null ? dir : UniFile.fromFile(NMBAppConfig.getImageDir()); }
Example 5
Source File: ContactListManagerAdapter.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
void insertBlockedContactToDataBase(Contact contact) { // Remove the blocked contact if it already exists, to avoid duplicates and // handle the odd case where a blocked contact's nickname has changed removeBlockedContactFromDataBase(contact); Uri.Builder builder = Imps.BlockedList.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, mConn.getProviderId()); ContentUris.appendId(builder, mConn.getAccountId()); Uri uri = builder.build(); String username = mAdaptee.normalizeAddress(contact.getAddress().getAddress()); ContentValues values = new ContentValues(2); values.put(Imps.BlockedList.USERNAME, username); values.put(Imps.BlockedList.NICKNAME, contact.getName()); mResolver.insert(uri, values); mValidatedBlockedContacts.add(username); }
Example 6
Source File: WXNavigatorModule.java From weex with Apache License 2.0 | 5 votes |
@WXModuleAnno public void push(String param, final String callbackId) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, WXConst.MSG_SUCCESS); return; } } try { JSONObject jsonObject = new JSONObject(param); String url = jsonObject.optString(URL, ""); if (!TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme("http"); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, WXConst.MSG_SUCCESS); } } catch (Exception e) { WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e)); WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, WXConst.MSG_FAILED); } } WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, WXConst.MSG_FAILED); }
Example 7
Source File: SubjectViewerFragment.java From android-galaxyzoo with GNU General Public License v3.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(final int loaderId, final Bundle bundle) { if (loaderId != URL_LOADER) { return null; } final String itemId = getItemId(); if (TextUtils.isEmpty(itemId)) { return null; } //Asynchronously get the actual ID, //because we have just asked for the "next" item. final Activity activity = getActivity(); final Uri.Builder builder = Item.ITEMS_URI.buildUpon(); builder.appendPath(itemId); showLoadingView(true); return new CursorLoader( activity, builder.build(), mColumns, null, // No where clause, return all records. We already specify just one via the itemId in the URI null, // No where clause, therefore no where column values. null // Use the default sort order. ); }
Example 8
Source File: Utility.java From facebooklogin with MIT License | 5 votes |
public static Uri buildUri(String authority, String path, Bundle parameters) { Uri.Builder builder = new Uri.Builder(); builder.scheme(URL_SCHEME); builder.authority(authority); builder.path(path); for (String key : parameters.keySet()) { Object parameter = parameters.get(key); if (parameter instanceof String) { builder.appendQueryParameter(key, (String) parameter); } } return builder.build(); }
Example 9
Source File: BookmarkUIState.java From 365browser with Apache License 2.0 | 5 votes |
static Uri createFolderUrl(BookmarkId folderId) { Uri.Builder builder = Uri.parse(UrlConstants.BOOKMARKS_FOLDER_URL).buildUpon(); // Encodes the path and appends it to the base url. A simple appending // does not work because there might be spaces in suffix. builder.appendPath(folderId.toString()); return builder.build(); }
Example 10
Source File: PhotoProvider.java From MagicalCamera with Apache License 2.0 | 5 votes |
public static Uri getPhotoUri(File file) { Uri outputUri = Uri.fromFile(file); Uri.Builder builder = new Uri.Builder() .authority(CONTENT_PROVIDER_AUTHORITY) .scheme("file") .path(outputUri.getPath()) .query(outputUri.getQuery()) .fragment(outputUri.getFragment()); return builder.build(); }
Example 11
Source File: ChanLocator.java From Dashchan with Apache License 2.0 | 5 votes |
@Public public final Uri buildPathWithSchemeHost(boolean useHttps, String host, String... segments) { Uri.Builder builder = new Uri.Builder().scheme(getPreferredScheme(useHttps)).authority(host); for (int i = 0; i < segments.length; i++) { String segment = segments[i]; if (segment != null) { builder.appendEncodedPath(segment.replaceFirst("^/+", "")); } } return builder.build(); }
Example 12
Source File: HttpWmsTileDataSource.java From hellomap3d-android with MIT License | 5 votes |
private Uri.Builder createBaseUri(String request, String srs) { Uri.Builder uri = Uri.parse(baseUrl).buildUpon(); uri.appendQueryParameter("LAYERS", layer); uri.appendQueryParameter("FORMAT", format); uri.appendQueryParameter("SERVICE", "WMS"); uri.appendQueryParameter("VERSION", "1.1.0"); uri.appendQueryParameter("REQUEST", request); uri.appendQueryParameter("STYLES", style); uri.appendQueryParameter("EXCEPTIONS", "application/vnd.ogc.se_inimage"); uri.appendQueryParameter("SRS", srs); uri.appendQueryParameter("WIDTH", Integer.toString(tileSize)); uri.appendQueryParameter("HEIGHT", Integer.toString(tileSize)); return uri; }
Example 13
Source File: OauthWebViewActivity.java From UPPlatform_Android_SDK with Apache License 2.0 | 5 votes |
/** * Launch a webview to start client authentication to obtain a token. * @param activity - The activity instance that will get callback * @param request_code - The request code used for startActivityForResult * @param clientId - The client id * @param callbackUrl - OAuth Callback used * @param authScope - Scope of Authentication */ public static void connect(Activity activity, int request_code, String clientId, String callbackUrl, ArrayList<UpPlatformAuthScope> authScope) { Uri.Builder builder = OauthUtils.setOauthParameters(clientId, callbackUrl, authScope); Intent intent = new Intent(OauthWebViewActivity.class.getName()); intent.putExtra(UpPlatformSdkConstants.AUTH_URI, builder.build()); activity.startActivityForResult(intent, request_code); }
Example 14
Source File: ConversationActivity.java From TranslateApp with GNU General Public License v3.0 | 5 votes |
@Override protected ArrayList<String> doInBackground(Void... params) { Uri baseUri = Uri.parse(BASE_REQ_URL); Uri.Builder uriBuilder = baseUri.buildUpon(); uriBuilder.appendPath("getLangs") .appendQueryParameter("key",getString(R.string.API_KEY)) .appendQueryParameter("ui","en"); Log.e("String Url ---->",uriBuilder.toString()); return QueryUtils.fetchLanguages(uriBuilder.toString()); }
Example 15
Source File: DefaultUriAdapter.java From weex-uikit with MIT License | 5 votes |
private Uri.Builder buildRelativeURI(Uri.Builder resultBuilder, Uri base, Uri uri) { if (uri.getAuthority() != null) { return resultBuilder.scheme(base.getScheme()); } else { resultBuilder .encodedAuthority(base.getEncodedAuthority()) .scheme(base.getScheme()) .path(null); if (uri.getPath().startsWith("/")) { //relative to root resultBuilder.appendEncodedPath(uri.getEncodedPath().substring(1)); } else { List<String> segments = base.getPathSegments(); //ignore last segment if not end with / int ignoreLast = 1; if (base.getPath().endsWith("/")) { ignoreLast = 0; } for (int i = 0, len = segments.size() - ignoreLast; i < len; i++) { resultBuilder.appendEncodedPath(segments.get(i)); } resultBuilder.appendEncodedPath(uri.getEncodedPath()); } return resultBuilder; } }
Example 16
Source File: PurchaseWemovecoinsActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private void loadWebView(String sum, String name, String currencyName, String email, String phoneCode, String phoneNumber, String generatedAddress) { String url = "https://guarda.co"; if ("wemovecoins".equals(serviceName)) { Uri.Builder builder = new Uri.Builder(); String protocol = MAIN_HTTP_PROTOCOL; if (Build.VERSION.SDK_INT <= 18) protocol = TEST_HTTP_PROTOCOL; builder.scheme(protocol) .authority(MAIN_ENDPOINT) .appendQueryParameter("amount", sum) .appendQueryParameter("currency", currencyName) .appendQueryParameter("name", name) .appendQueryParameter("cryptoAddress", generatedAddress) .appendQueryParameter("email", email) .appendQueryParameter("phoneCode", phoneCode) .appendQueryParameter("phonenumber", phoneNumber) .appendQueryParameter("returnurl", Common.SITE_APP_LINK); url = builder.build().toString(); continueLoadWebView(url); } else if ("coinify".equals(serviceName)) { coinify(); } else { IndacoinManager.createTransaction(sum, "btc", generatedAddress, email, new Callback2<String, IndacoinManager.CreateTransactionRespModel>() { @Override public void onResponse(String status, IndacoinManager.CreateTransactionRespModel resp) { if (resp != null) continueLoadWebView(resp.paymentUrl); else continueLoadWebView_fail(); } }); } }
Example 17
Source File: Utils.java From android-galaxyzoo with GNU General Public License v3.0 | 4 votes |
public static Uri getItemUri(final String itemId) { final Uri.Builder uriBuilder = Item.ITEMS_URI.buildUpon(); uriBuilder.appendPath(itemId); return uriBuilder.build(); }
Example 18
Source File: DeviceRootNPLocation.java From edslite with GNU General Public License v2.0 | 4 votes |
@Override public Uri.Builder makeFullUri() { return super.makeFullUri().scheme(URI_SCHEME); }
Example 19
Source File: AuthenticationRequestTest.java From blade-player with GNU General Public License v3.0 | 3 votes |
@Test public void shouldUseDefaultCampaign() { AuthenticationRequest authenticationRequest = new AuthenticationRequest.Builder(mClientId, mResponseType, mRedirectUri) .build(); assertEquals(authenticationRequest.getCampaign(), mDefaultCampaign); Uri.Builder uriBuilder = getBaseAuthUri(mClientId, mResponseType.toString(), mRedirectUri, mDefaultCampaign); Uri uri = uriBuilder.build(); assertEquals(uri, authenticationRequest.toUri()); }
Example 20
Source File: Imps.java From Zom-Android-XMPP with GNU General Public License v3.0 | 3 votes |
public static int updateMessageBody(ContentResolver resolver, String id, String body, String mimeType) { Uri.Builder builder = Imps.Messages.OTR_MESSAGES_CONTENT_URI.buildUpon(); builder.appendPath(id); ContentValues values = new ContentValues(); values.put(Imps.Messages.BODY, body); if (mimeType != null) values.put(Imps.Messages.MIME_TYPE, mimeType); return resolver.update(builder.build(), values, null, null); }