List of usage examples for android.content Intent getScheme
public @Nullable String getScheme()
From source file:de.kodejak.hashr.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle();//from www . j a v a 2 s. co m // Set a toolbar which will replace the action bar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), toolbar); Intent intent = getIntent(); String action = intent.getAction(); if (action.compareTo(Intent.ACTION_VIEW) == 0) { String scheme = intent.getScheme(); ContentResolver resolver = getContentResolver(); if (scheme.compareTo(ContentResolver.SCHEME_CONTENT) == 0) { Uri uri = intent.getData(); String name = getContentName(resolver, uri); Log.v("tag", "Content intent detected: " + action + " : " + intent.getDataString() + " : " + intent.getType() + " : " + name); //What TODO? } else if (scheme.compareTo(ContentResolver.SCHEME_FILE) == 0) { lastSumFile = intent.getData().getPath(); forcedFragmentNum = prepareOpenSumFile(lastSumFile); if (forcedFragmentNum > -1) { mNavigationDrawerFragment.selectItem(forcedFragmentNum); } } } }
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();//from w w w .j a v a 2 s . com 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; } // 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); } }
From source file:org.awesomeapp.messenger.ui.AddContactActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setTitle(""); mApp = (ImApp) getApplication();/*w w w . j av a 2 s . c o m*/ mHandler = new SimpleAlertHandler(this); setContentView(R.layout.add_contact_activity); TextView label = (TextView) findViewById(R.id.input_contact_label); mNewAddress = (EditText) findViewById(R.id.email); mNewAddress.addTextChangedListener(mTextWatcher); mNewAddress.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { if (actionId == EditorInfo.IME_ACTION_SEND) { inviteBuddies(); } return false; } }); Intent intent = getIntent(); String scheme = intent.getScheme(); if (TextUtils.equals(scheme, "xmpp")) { addContactFromUri(intent.getData()); } setupActions(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:com.zhongzilu.bit100.view.activity.EditorActivity.java
private void getIntentData() { Intent intent = this.getIntent(); int flags = intent.getFlags(); if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) { if (intent.getAction() != null && Intent.ACTION_VIEW.equals(intent.getAction())) { if (SCHEME_FILE.equals(intent.getScheme())) { // // String type = getIntent().getType(); // mImportingUri=file:///storage/emulated/0/Vlog.xml intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Uri uri = intent.getData(); if (uri != null && SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) { // currentFilePath = FileUtils.uri2FilePath(getBaseContext(), uri); }// w w w .ja va2 s.c o m } } } }
From source file:ren.qinc.markdowneditors.view.EditorActivity.java
private void getIntentData() { Intent intent = this.getIntent(); int flags = intent.getFlags(); if ((flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) { if (intent.getAction() != null && Intent.ACTION_VIEW.equals(intent.getAction())) { if (SCHEME_FILE.equals(intent.getScheme())) { // String type = getIntent().getType(); // mImportingUri=file:///storage/emulated/0/Vlog.xml intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Uri uri = intent.getData(); if (uri != null && SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) { // currentFilePath = FileUtils.uri2FilePath(getBaseContext(), uri); }/*w w w . j av a 2 s . c o m*/ } } } }
From source file:org.thialfihar.android.apg.ui.ImportKeysActivity.java
protected void handleActions(Bundle savedInstanceState, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras();/* ww w. j a v a2 s. co m*/ Uri dataUri = intent.getData(); String scheme = intent.getScheme(); if (extras == null) { extras = new Bundle(); } if (Intent.ACTION_VIEW.equals(action)) { // Android's Action when opening file associated to Keychain (see AndroidManifest.xml) // override action to delegate it to Keychain's ACTION_IMPORT_KEY action = ACTION_IMPORT_KEY; } if (scheme != null && scheme.toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) { /* Scanning a fingerprint directly with Barcode Scanner */ loadFromFingerprintUri(savedInstanceState, dataUri); } else if (ACTION_IMPORT_KEY.equals(action)) { /* Keychain's own Actions */ // display file fragment loadNavFragment(1, null); if (dataUri != null) { // action: directly load data startListFragment(savedInstanceState, null, dataUri, null); } else if (extras.containsKey(EXTRA_KEY_BYTES)) { byte[] importData = intent.getByteArrayExtra(EXTRA_KEY_BYTES); // action: directly load data startListFragment(savedInstanceState, importData, null, null); } } else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action)) { String query = null; if (extras.containsKey(EXTRA_QUERY)) { query = extras.getString(EXTRA_QUERY); } else if (extras.containsKey(EXTRA_KEY_ID)) { long keyId = intent.getLongExtra(EXTRA_KEY_ID, 0); if (keyId != 0) { query = PgpKeyHelper.convertKeyIdToHex(keyId); } } else if (extras.containsKey(EXTRA_FINGERPRINT)) { String fingerprint = intent.getStringExtra(EXTRA_FINGERPRINT); if (fingerprint != null) { query = "0x" + fingerprint; } } else { Log.e(Constants.TAG, "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', " + "'key_id', or 'fingerprint' extra!"); return; } // display keyserver fragment with query Bundle args = new Bundle(); args.putString(ImportKeysServerFragment.ARG_QUERY, query); loadNavFragment(0, args); // action: search immediately startListFragment(savedInstanceState, null, null, query); } else if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) { // NOTE: this only displays the appropriate fragment, no actions are taken loadNavFragment(1, null); // no immediate actions! startListFragment(savedInstanceState, null, null, null); } else if (ACTION_IMPORT_KEY_FROM_QR_CODE.equals(action)) { // also exposed in AndroidManifest // NOTE: this only displays the appropriate fragment, no actions are taken loadNavFragment(2, null); // no immediate actions! startListFragment(savedInstanceState, null, null, null); } else if (ACTION_IMPORT_KEY_FROM_NFC.equals(action)) { // NOTE: this only displays the appropriate fragment, no actions are taken loadNavFragment(3, null); // no immediate actions! startListFragment(savedInstanceState, null, null, null); } else { startListFragment(savedInstanceState, null, null, null); } }
From source file:com.coinblesk.client.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPrefUtils.initDefaults(this, R.xml.settings_pref, false); final AppConfig appConfig = ((CoinbleskApp) getApplication()).getAppConfig(); try {//from ww w. j av a 2 s. c o m AdditionalServiceUtils.setSessionID(this, null); } catch (Exception e) { Log.e(TAG, "Could not set sessionID: ", e); } UpgradeUtils upgradeUtils = new UpgradeUtils(); upgradeUtils.checkUpgrade(this, appConfig.getNetworkParameters()); startWalletService(false); setContentView(R.layout.activity_main); initToolbar(); initNavigationView(); initViewPager(); final Intent intent = getIntent(); final String scheme = intent.getScheme(); if (scheme != null && scheme.equals(appConfig.getNetworkParameters().getUriScheme())) { final String uri = intent.getDataString(); try { BitcoinURI bitcoinURI = new BitcoinURI(uri); SendDialogFragment.newInstance(bitcoinURI.getAddress(), bitcoinURI.getAmount()) .show(getFragmentManager(), "send-dialog"); } catch (BitcoinURIParseException e) { Log.w(TAG, "Could not parse Bitcoin URI: " + uri); } } ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, FINE_LOCATION_PERMISSION_REQUEST); checkVersionCompatibility(appConfig); }
From source file:com.code.android.vibevault.ShowDetailsScreen.java
/** Create the activity, taking into account ongoing dialogs or already downloaded data. * * If there is a retained ParseShowDetailsPageTask, set its parent * activity to the newly created ShowDetailsScreen (the old one was * destroyed because of an orientation change or something. This * way, the ParseShowDetailsPageTask does not leak any of the Views * from the old ShowDetailsScreen. Also, grab the songs from the * ParseShowDetailsPageTask to refresh the list of songs with. *//*from ww w.j a v a 2 s .c om*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.show_details_screen); Intent intent = getIntent(); Bundle b = intent.getExtras(); if (b != null) { show = (ArchiveShowObj) b.get("Show"); } if (show == null) { if (intent.getScheme().equals("http")) { Uri link = intent.getData(); String linkString = link.toString(); if (linkString.contains("/download/")) { String[] paths = linkString.split("/"); for (int i = 0; i < paths.length; i++) { if (paths[i].equals("download")) { show = new ArchiveShowObj(Uri.parse("http://www.archive.org/details/" + paths[i + 1]), true); show.setSelectedSong(linkString); } } } else { show = new ArchiveShowObj(link, false); } } } // // showTitle = show.getArtistAndTitle(); showLabel = (TextView) findViewById(R.id.ShowLabel); showLabel.setText(showTitle); trackList = (ListView) findViewById(R.id.SongsListView); trackList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { playShow(position); Intent i = new Intent(ShowDetailsScreen.this, NowPlayingScreen.class); startActivity(i); } }); trackList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(Menu.NONE, VibeVault.ADD_SONG_TO_QUEUE, Menu.NONE, "Add to playlist"); menu.add(Menu.NONE, VibeVault.DOWNLOAD_SONG, Menu.NONE, "Download Song"); menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Song"); } }); downloadLinks = new ArrayList<ArchiveSongObj>(); Object retained = getLastNonConfigurationInstance(); if (retained instanceof ParseShowDetailsPageTask) { workerTask = (ParseShowDetailsPageTask) retained; workerTask.setActivity(this); downloadLinks = workerTask.songs; } else if (show.getShowURL() != null) { workerTask = new ParseShowDetailsPageTask(this); workerTask.execute(show); } }
From source file:id.nci.stm_9.ImportKeysActivity.java
protected void handleActions(Bundle savedInstanceState, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras();//from w w w . j av a 2 s . com if (extras == null) { extras = new Bundle(); } /** * Android Standard Actions */ if (Intent.ACTION_VIEW.equals(action)) { // Android's Action when opening file associated to Keychain (see AndroidManifest.xml) // override action to delegate it to Keychain's ACTION_IMPORT_KEY action = ACTION_IMPORT_KEY; } /** * Keychain's own Actions */ if (ACTION_IMPORT_KEY.equals(action)) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { String importFilename = intent.getData().getPath(); // display selected filename getSupportActionBar().setSelectedNavigationItem(0); Bundle args = new Bundle(); args.putString(ImportKeysFileFragment.ARG_PATH, importFilename); loadFragment(ImportKeysFileFragment.class, args, mNavigationStrings[0]); // directly load data startListFragment(savedInstanceState, null, importFilename); } else if (extras.containsKey(EXTRA_KEY_BYTES)) { byte[] importData = intent.getByteArrayExtra(EXTRA_KEY_BYTES); // directly load data startListFragment(savedInstanceState, importData, null); } } else { // Internal actions startListFragment(savedInstanceState, null, null); if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) { getSupportActionBar().setSelectedNavigationItem(0); loadFragment(ImportKeysFileFragment.class, null, mNavigationStrings[0]); } // } else if (ACTION_IMPORT_KEY_FROM_QR_CODE.equals(action)) { // getSupportActionBar().setSelectedNavigationItem(2); // loadFragment(ImportKeysQrCodeFragment.class, null, mNavigationStrings[2]); // } else if (ACTION_IMPORT_KEY_FROM_NFC.equals(action)) { // getSupportActionBar().setSelectedNavigationItem(3); // loadFragment(ImportKeysNFCFragment.class, null, mNavigationStrings[3]); // } } }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysActivity.java
protected void handleActions(Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras();//w w w . j av a 2 s . c om if (extras == null) { extras = new Bundle(); } /** * Android Standard Actions */ if (Intent.ACTION_VIEW.equals(action)) { // Android's Action when opening file associated to APG (see AndroidManifest.xml) // override action to delegate it to APGs ACTION_IMPORT action = ACTION_IMPORT; } /** * APG's own Actions */ if (ACTION_IMPORT.equals(action)) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { mImportFilename = intent.getData().getPath(); mImportData = null; } else if (extras.containsKey(EXTRA_TEXT)) { mImportData = intent.getStringExtra(EXTRA_TEXT).getBytes(); mImportFilename = null; } else if (extras.containsKey(EXTRA_KEYRING_BYTES)) { mImportData = intent.getByteArrayExtra(EXTRA_KEYRING_BYTES); mImportFilename = null; } loadKeyListFragment(); } else if (ACTION_IMPORT_FROM_FILE.equals(action)) { if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { mImportFilename = intent.getData().getPath(); mImportData = null; } showImportFromFileDialog(); } else if (ACTION_IMPORT_FROM_QR_CODE.equals(action)) { importFromQrCode(); } else if (ACTION_IMPORT_FROM_NFC.equals(action)) { importFromNfc(); } }