List of usage examples for android.net Uri getScheme
@Nullable public abstract String getScheme();
From source file:com.google.plus.samples.photohunt.ThemeViewActivity.java
@Override public void onActivityResult(int requestCode, int responseCode, Intent intent) { super.onActivityResult(requestCode, responseCode, intent); switch (requestCode) { case REQUEST_CODE_IMAGE_CAPTURE: if (responseCode == RESULT_OK) { sendImage(Intents.getPhotoImageUri().getPath(), mTheme.id); }/*from w w w .j av a 2 s . c om*/ break; case REQUEST_CODE_IMAGE_SELECT: if (responseCode == RESULT_OK && intent != null && intent.getData() != null) { String imageUriString = intent.getDataString(); Uri imageUri = intent.getData(); if ("content".equals(imageUri.getScheme())) { Cursor cursor = getContentResolver().query(imageUri, new String[] { Media.DATA }, null, null, null); int column_index = cursor.getColumnIndexOrThrow(Media.DATA); cursor.moveToFirst(); imageUriString = cursor.getString(column_index); } sendImage(imageUriString, mTheme.id); } break; } }
From source file:com.google.android.apps.paco.ExploreDataActivity.java
private WebViewClient createWebViewClientThatHandlesFileLinksForCharts() { WebViewClient webViewClient = new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { Uri uri = Uri.parse(url); if (uri.getScheme().startsWith("http")) { return true; }/* w w w .j av a 2 s. c om*/ view.loadUrl(FeedbackActivity.stripQuery(url)); return true; } }; return webViewClient; }
From source file:eu.e43.impeller.activity.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); m_pendingIntent = false;/*from w w w . j a v a 2 s . co m*/ Log.i(TAG, "New intent " + intent); if (intent.hasExtra(Constants.EXTRA_ACCOUNT)) { haveGotAccount((Account) intent.getParcelableExtra(Constants.EXTRA_ACCOUNT)); } if (m_account == null) { setIntent(intent); m_pendingIntent = true; return; } String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { Uri uri = intent.getData(); if (uri == null) return; Uri id = null; if (uri.getScheme().equals("content") && uri.getHost().equals("eu.e43.impeller.content")) { id = Uri.parse(uri.getLastPathSegment()); } else { id = uri; } setIntent(intent); showObjectInMode(Mode.OBJECT, id); } else if (Constants.ACTION_SHOW_FEED.equals(action)) { showFeed((Constants.FeedID) intent.getSerializableExtra(Constants.EXTRA_FEED_ID)); } else { Log.d(TAG, "Unknown new intent " + intent); } }
From source file:mobisocial.noteshere.util.UriImage.java
public UriImage(Context context, Uri uri) { if ((null == context) || (null == uri)) { throw new IllegalArgumentException(); }/*from w w w. j a va 2s .c o m*/ mRotation = rotationForImage(context, uri); String scheme = uri.getScheme(); if (scheme.equals("content")) { try { initFromContentUri(context, uri); } catch (Exception e) { Log.w(TAG, "last-ditch image params"); mPath = uri.getPath(); mContentType = context.getContentResolver().getType(uri); } } else if (uri.getScheme().equals("file")) { initFromFile(context, uri); } else { mPath = uri.getPath(); } mSrc = mPath.substring(mPath.lastIndexOf('/') + 1); if (mSrc.startsWith(".") && mSrc.length() > 1) { mSrc = mSrc.substring(1); } // Some MMSCs appear to have problems with filenames // containing a space. So just replace them with // underscores in the name, which is typically not // visible to the user anyway. mSrc = mSrc.replace(' ', '_'); mContext = context; mUri = uri; }
From source file:net.sourceforge.servestream.fragment.BrowseFragment.java
private void browseTo(Uri uri) { mStepsBack = 0;//from w ww . j a v a2s . c o m mDirectory = new UriBean[1000]; mDirectory[mStepsBack] = TransportFactory.getTransport(uri.getScheme()).createUri(uri); refreshList(); }
From source file:com.openerp.base.ir.Attachment.java
private String[] getFileName(Uri uri) { String[] file_info = null;/*ww w.ja v a 2 s .co m*/ String filename = ""; String file_type = ""; if (uri.getScheme().toString().compareTo("content") == 0) { Cursor cursor = mContext.getContentResolver().query(uri, null, null, null, null); if (cursor.moveToFirst()) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); filename = cursor.getString(column_index); File fl = new File(filename); filename = fl.getName(); } file_type = mContext.getContentResolver().getType(uri); } else if (uri.getScheme().compareTo("file") == 0) { filename = uri.getLastPathSegment().toString(); file_type = "file"; } else { filename = filename + "_" + uri.getLastPathSegment(); file_type = "file"; } file_info = new String[] { filename, file_type }; return file_info; }
From source file:com.owncloud.android.ui.helpers.UriUploader.java
public UriUploaderResultCode uploadUris() { try {//w w w . j av a 2 s . c om List<Uri> contentUris = new ArrayList<>(); List<String> contentRemotePaths = new ArrayList<>(); int schemeFileCounter = 0; for (Parcelable sourceStream : mUrisToUpload) { Uri sourceUri = (Uri) sourceStream; if (sourceUri != null) { String displayName = UriUtils.getDisplayNameForUri(sourceUri, mActivity); if (displayName == null) { displayName = generateDiplayName(); } String remotePath = mUploadPath + displayName; if (ContentResolver.SCHEME_CONTENT.equals(sourceUri.getScheme())) { contentUris.add(sourceUri); contentRemotePaths.add(remotePath); } else if (ContentResolver.SCHEME_FILE.equals(sourceUri.getScheme())) { /// file: uris should point to a local file, should be safe let FileUploader handle them requestUpload(sourceUri.getPath(), remotePath); schemeFileCounter++; } } } if (!contentUris.isEmpty()) { /// content: uris will be copied to temporary files before calling {@link FileUploader} copyThenUpload(contentUris.toArray(new Uri[contentUris.size()]), contentRemotePaths.toArray(new String[contentRemotePaths.size()])); } else if (schemeFileCounter == 0) { mCode = UriUploaderResultCode.ERROR_NO_FILE_TO_UPLOAD; } } catch (SecurityException e) { mCode = UriUploaderResultCode.ERROR_READ_PERMISSION_NOT_GRANTED; Log_OC.e(TAG, "Permissions fail", e); } catch (Exception e) { mCode = UriUploaderResultCode.ERROR_UNKNOWN; Log_OC.e(TAG, "Unexpected error", e); } return mCode; }
From source file:com.polyvi.xface.extension.XAppExt.java
private void setDirPermisionUntilWorkspace(XIWebContext webContext, Uri uri) { // ??/*w ww .j a v a2 s . co m*/ // ?:?workspace if (!XConstant.FILE_SCHEME.contains(uri.getScheme())) { return; } String filePath = uri.getPath(); String workspace = new File(webContext.getWorkSpace()).getAbsolutePath(); File fileObj = new File(filePath); do { String path = fileObj.getAbsolutePath(); // ?? XFileUtils.setPermission(XFileUtils.ALL_PERMISSION, path); fileObj = new File(fileObj.getParent()); } while (!fileObj.getAbsolutePath().equals(workspace)); }
From source file:com.activiti.android.app.fragments.account.AccountEditFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (getArguments() != null) { accountId = getArguments().getLong(ARGUMENT_ACCOUNT_ID); }//from w w w. jav a 2s.c om acc = ActivitiAccountManager.getInstance(getActivity()).getByAccountId(accountId); Uri serverUri = Uri.parse(acc.getServerUrl()); if (serverUri.getPath().equals("/activiti-app")) { // It's default url https = ("https".equals(serverUri.getScheme().toLowerCase())); hostname = serverUri.getAuthority(); } else { // It's not default we display full url in hostname hostname = acc.getServerUrl(); hide(R.id.signing_https); } // TITLE TextView tv = (TextView) viewById(R.id.signin_title); tv.setText(R.string.settings_userinfo_account_summary); // USERNAME mEmailView = (MaterialAutoCompleteTextView) viewById(R.id.username); Account[] accounts = AccountManager.get(getActivity()).getAccounts(); List<String> names = new ArrayList<>(accounts.length); String accountName; for (int i = 0; i < accounts.length; i++) { accountName = accounts[i].name; if (!TextUtils.isEmpty(accountName) && !names.contains(accountName)) { names.add(accounts[i].name); } } ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, names); mEmailView.setAdapter(adapter); mEmailView.setText(acc.getUsername()); // PASSWORD mPasswordView = (EditText) viewById(R.id.password); mPasswordView.setText(acc.getPassword()); Button mEmailSignInButton = (Button) viewById(R.id.email_sign_in_button); mEmailSignInButton.setText(R.string.general_action_confirm); mEmailSignInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { attemptLogin(); } }); mProgressView = viewById(R.id.login_progress); mFormView = viewById(R.id.login_form); // Server part httpsView = (CheckBox) viewById(R.id.signing_https); httpsView.setChecked(https); hostnameView = (MaterialEditText) viewById(R.id.signing_hostname); hostnameView.setText(hostname); show(R.id.server_form); }
From source file:com.jtechme.apphub.FDroid.java
private void handleSearchOrAppViewIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); performSearch(query);/* w w w . j a v a 2 s.com*/ return; } final Uri data = intent.getData(); if (data == null) { return; } final String scheme = data.getScheme(); final String path = data.getPath(); String packageName = null; String query = null; if (data.isHierarchical()) { final String host = data.getHost(); if (host == null) { return; } switch (host) { case "f-droid.org": if (path.startsWith("/repository/browse")) { // http://f-droid.org/repository/browse?fdfilter=search+query query = UriCompat.getQueryParameter(data, "fdfilter"); // http://f-droid.org/repository/browse?fdid=packageName packageName = UriCompat.getQueryParameter(data, "fdid"); } else if (path.startsWith("/app")) { // http://f-droid.org/app/packageName packageName = data.getLastPathSegment(); if ("app".equals(packageName)) { packageName = null; } } break; case "details": // market://details?id=app.id packageName = UriCompat.getQueryParameter(data, "id"); break; case "search": // market://search?q=query query = UriCompat.getQueryParameter(data, "q"); break; case "play.google.com": if (path.startsWith("/store/apps/details")) { // http://play.google.com/store/apps/details?id=app.id packageName = UriCompat.getQueryParameter(data, "id"); } else if (path.startsWith("/store/search")) { // http://play.google.com/store/search?q=foo query = UriCompat.getQueryParameter(data, "q"); } break; case "apps": case "amazon.com": case "www.amazon.com": // amzn://apps/android?p=app.id // http://amazon.com/gp/mas/dl/android?s=app.id packageName = UriCompat.getQueryParameter(data, "p"); query = UriCompat.getQueryParameter(data, "s"); break; } } else if ("fdroid.app".equals(scheme)) { // fdroid.app:app.id packageName = data.getSchemeSpecificPart(); } else if ("fdroid.search".equals(scheme)) { // fdroid.search:query query = data.getSchemeSpecificPart(); } if (!TextUtils.isEmpty(query)) { // an old format for querying via packageName if (query.startsWith("pname:")) packageName = query.split(":")[1]; // sometimes, search URLs include pub: or other things before the query string if (query.contains(":")) query = query.split(":")[1]; } if (!TextUtils.isEmpty(packageName)) { Utils.debugLog(TAG, "FDroid launched via app link for '" + packageName + "'"); Intent intentToInvoke = new Intent(this, AppDetails.class); intentToInvoke.putExtra(AppDetails.EXTRA_APPID, packageName); startActivity(intentToInvoke); } else if (!TextUtils.isEmpty(query)) { Utils.debugLog(TAG, "FDroid launched via search link for '" + query + "'"); performSearch(query); } }