List of usage examples for android.net Uri getScheme
@Nullable public abstract String getScheme();
From source file:com.danjarvis.documentcontract.DocumentContract.java
/** * Gets the contract details for the provided content URI. * * @return Contract serialized to a JSONObject *//*from w ww .ja v a 2 s. c o m*/ private void getContract(JSONObject args, CallbackContext callback) { try { Uri uri; Cursor cursor; JSONObject response = new JSONObject(); uri = getUri(args); if (null == uri || !(uri.getScheme().equals(ContentResolver.SCHEME_CONTENT))) { callback.error(INVALID_URI_ERROR); return; } cursor = cordova.getActivity().getContentResolver().query(uri, getColumns(args), null, null, null); if (null != cursor && cursor.moveToFirst()) { for (String col : cursor.getColumnNames()) response.put(col, cursor.getString(cursor.getColumnIndex(col))); } cursor.close(); callback.success(response); } catch (JSONException je) { callback.error(je.getMessage()); } }
From source file:net.openid.appauthdemo.Configuration.java
Uri getRequiredConfigWebUri(String propName) throws InvalidConfigurationException { Uri uri = getRequiredConfigUri(propName); String scheme = uri.getScheme(); if (TextUtils.isEmpty(scheme) || !("http".equals(scheme) || "https".equals(scheme))) { throw new InvalidConfigurationException(propName + " must have an http or https scheme"); }//w w w . ja va2 s .c o m return uri; }
From source file:com.shopify.sample.activity.base.SampleActivity.java
@Override protected void onResume() { super.onResume(); // If we are being launched by a url scheme, check the scheme and retrieve the checkout token if provided Intent intent = getIntent();/* w w w. j ava2 s . c o m*/ Uri uri = intent.getData(); String scheme = getString(R.string.web_return_to_scheme); if (uri != null && TextUtils.equals(uri.getScheme(), scheme)) { // If the app was launched using the scheme, we know we just successfully completed an order onCheckoutComplete(); } }
From source file:com.wanikani.androidnotifier.ImportActivity.java
protected void checkIntent(Intent intent) { String action;// w w w .jav a 2 s .c o m Uri uri; action = intent.getAction(); if (action.equals(Intent.ACTION_VIEW) || action.equals(Intent.ACTION_EDIT)) { uri = intent.getData(); if (uri != null && uri.getScheme().equals("file")) lview.setText(uri.getPath()); } }
From source file:com.mobage.android.shellappsdk.sample.GameWebView.java
@Override public void loadUrl(String url) { Uri uri = Uri.parse(url); if (!"javascript".equalsIgnoreCase(uri.getScheme())) { // "file:" ????????????? if ("file".equalsIgnoreCase(uri.getScheme())) { super.loadUrl("about:blank"); Log.w(TAG, "Prevented loading file URL: " + url); return; }//from w w w . j av a 2 s. co m // ??????????????????? if (handleExternalDomainUrl(url)) { Log.w(TAG, "Prevented loading external URL: " + url); return; } } super.loadUrl(url); }
From source file:com.dena.app.bootloadhid.MainFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (Activity.RESULT_OK == resultCode && null != data) { Uri uri = data.getData(); if (null != uri && "file".equalsIgnoreCase(uri.getScheme())) { setFilePath(uri.getPath());// ww w. ja va 2s . c o m } } }
From source file:drupalfit.sample.HomeActivity.java
@OnClick(R.id.connect_facebook) public void connectFacebook() { if (TextUtils.isEmpty(endpoint.getText().toString())) { Toast.makeText(HomeActivity.this, "failure", Toast.LENGTH_LONG).show(); return;/* ww w .ja v a 2 s .c om*/ } progress(); String restEndpoint = endpoint.getText().toString(); Uri uri = Uri.parse(restEndpoint); String oauthEndpoint = uri.getScheme() + "://" + uri.getAuthority() + "/oauth2"; DrupalManager.get().setEndpoint(restEndpoint) .setProvider(this, DrupalManager.FACEBOOK, token.getText().toString()).build(); DrupalManager.get().getProfile(new Callback<User>() { // direct access profile, DrupalManager will try to connect @Override public void success(User user, Response response) { done(); Toast.makeText(HomeActivity.this, "success: " + "uid:" + user.uid + ", name: " + user.name, Toast.LENGTH_LONG).show(); Log8.d(user.name); Log8.d(user.mail); Log8.d(user.uid); } @Override public void failure(RetrofitError error) { done(); Toast.makeText(HomeActivity.this, "failure: " + error, Toast.LENGTH_LONG).show(); Log8.d(error); } }); }
From source file:com.xabber.android.ui.activity.ContactViewer.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Intent.ACTION_VIEW.equals(getIntent().getAction())) { // View information about contact from system contact list Uri data = getIntent().getData(); if (data != null && "content".equals(data.getScheme())) { List<String> segments = data.getPathSegments(); if (segments.size() == 2 && "data".equals(segments.get(0))) { Long id;//from w w w .ja v a2 s.co m try { id = Long.valueOf(segments.get(1)); } catch (NumberFormatException e) { id = null; } if (id != null) // FIXME: Will be empty while application is loading for (RosterContact rosterContact : RosterManager.getInstance().getContacts()) if (id.equals(rosterContact.getViewId())) { account = rosterContact.getAccount(); bareAddress = rosterContact.getUser(); break; } } } } else { account = getAccount(getIntent()); bareAddress = getUser(getIntent()); } if (bareAddress != null && bareAddress.equalsIgnoreCase(GroupManager.IS_ACCOUNT)) { bareAddress = Jid.getBareAddress(AccountManager.getInstance().getAccount(account).getRealJid()); } if (account == null || bareAddress == null) { Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); finish(); return; } setContentView(R.layout.contact_viewer); if (savedInstanceState == null) { Fragment fragment; if (MUCManager.getInstance().hasRoom(account, bareAddress)) { fragment = ConferenceInfoFragment.newInstance(account, bareAddress); } else { fragment = ContactVcardViewerFragment.newInstance(account, bareAddress); } getFragmentManager().beginTransaction().add(R.id.scrollable_container, fragment).commit(); } bestContact = RosterManager.getInstance().getBestContact(account, bareAddress); toolbar = (Toolbar) findViewById(R.id.toolbar_default); toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { NavUtils.navigateUpFromSameTask(ContactViewer.this); } }); StatusBarPainter statusBarPainter = new StatusBarPainter(this); statusBarPainter.updateWithAccountName(account); final int accountMainColor = ColorManager.getInstance().getAccountPainter().getAccountMainColor(account); contactTitleView = findViewById(R.id.contact_title_expanded); findViewById(R.id.status_icon).setVisibility(View.GONE); contactTitleView.setBackgroundColor(accountMainColor); TextView contactNameView = (TextView) findViewById(R.id.name); contactNameView.setVisibility(View.INVISIBLE); collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle(bestContact.getName()); collapsingToolbar.setBackgroundColor(accountMainColor); collapsingToolbar.setContentScrimColor(accountMainColor); }
From source file:com.cnh.library.materialdrawer.view.BezelImageView.java
@Override public void setImageURI(Uri uri) { if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) { DrawerImageLoader.getInstance().setImage(this, uri, null); } else {//from w ww .j av a 2 s . c om super.setImageURI(uri); } }
From source file:com.raghu.test.widgets.BezelImageView.java
@Override public void setImageURI(Uri uri) { if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) { //DrawerImageLoader.getInstance().setImage(this, uri, null); } else {//from w w w.jav a 2 s .c o m super.setImageURI(uri); } }