List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:com.mobicage.rogerthat.NewsActivity.java
private void processIntent(Intent intent, Boolean start) { if (intent != null) { final String url = intent.getDataString(); if (url != null) { processUrl(url);//from w w w. ja v a 2 s .c o m } if (start) { mIdToShowAtTop = intent.getLongExtra("id", -1); } } }
From source file:org.fdroid.fdroid.net.DownloaderService.java
@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); Utils.debugLog(TAG, "Received Intent for downloading: " + intent + " (with a startId of " + startId + ")"); String uriString = intent.getDataString(); if (uriString == null) { Log.e(TAG, "Received Intent with no URI: " + intent); return;// w w w . j a v a 2 s. c om } if (ACTION_CANCEL.equals(intent.getAction())) { Utils.debugLog(TAG, "Cancelling download of " + uriString); if (isQueued(uriString)) { serviceHandler.removeMessages(what); } else if (isActive(uriString)) { downloader.cancelDownload(); } else { Log.e(TAG, "ACTION_CANCEL called on something not queued or running"); } QUEUE_WHATS.remove(uriString); if (isQueueEmpty()) { stopForeground(true); } } else if (ACTION_QUEUE.equals(intent.getAction())) { Message msg = serviceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = intent; msg.what = what++; serviceHandler.sendMessage(msg); QUEUE_WHATS.put(uriString, msg.what); Utils.debugLog(TAG, "Queued download of " + uriString + ". Now " + QUEUE_WHATS.size() + " downloads in the queue"); } else { Log.e(TAG, "Received Intent with unknown action: " + intent); } }
From source file:ca.rmen.android.poetassistant.main.MainActivity.java
@Override protected void onNewIntent(Intent intent) { Log.d(TAG, "onNewIntent() called with: " + "intent = [" + intent + "]"); setIntent(intent);//w ww . j av a2 s.c om // The user entered a search term either by typing or by voice if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getDataString(); if (TextUtils.isEmpty(query)) { query = intent.getStringExtra(SearchManager.QUERY); } if (TextUtils.isEmpty(query)) { CharSequence userQuery = intent.getCharSequenceExtra(SearchManager.USER_QUERY); if (!TextUtils.isEmpty(userQuery)) query = userQuery.toString(); } if (TextUtils.isEmpty(query)) return; mSearch.addSuggestions(query); mSearch.search(query); } // We got here from a deep link else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri data = getIntent().getData(); handleDeepLink(data); } // Play some text in the tts tab else if (Intent.ACTION_SEND.equals(intent.getAction())) { mBinding.viewPager.setCurrentItem(mPagerAdapter.getPositionForTab(Tab.READER)); String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); ReaderFragment readerFragment = (ReaderFragment) mPagerAdapter.getFragment(mBinding.viewPager, Tab.READER); readerFragment.setText(sharedText); } }
From source file:com.polyvi.xface.extension.XAppExt.java
private void registerInstallerReceiver(final XCallbackContext callbackCtx) { if (null == mInstallerReceiver) { mInstallerReceiver = new BroadcastReceiver() { @Override// w w w . j a v a 2s . c o m public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED") && (uninstallPackageName.equals(intent.getDataString().substring(8)))) { XExtensionResult result = new XExtensionResult(XExtensionResult.Status.OK); callbackCtx.sendExtensionResult(result); } if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) { XExtensionResult result = new XExtensionResult(XExtensionResult.Status.OK); callbackCtx.sendExtensionResult(result); } } }; IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); getContext().registerReceiver(mInstallerReceiver, filter); } }
From source file:arun.com.chromer.webheads.WebHeadService.java
private void processIntent(@Nullable Intent intent) { if (intent == null || intent.getDataString() == null) return; // don't do anything final boolean isForMinimized = intent.getBooleanExtra(EXTRA_KEY_MINIMIZE, false); final boolean isFromAmp = intent.getBooleanExtra(EXTRA_KEY_FROM_AMP, false); final boolean isIncognito = intent.getBooleanExtra(EXTRA_KEY_INCOGNITO, false); final String urlToLoad = intent.getDataString(); if (TextUtils.isEmpty(urlToLoad)) { Toast.makeText(this, R.string.invalid_link, LENGTH_SHORT).show(); return;// w w w . ja v a 2 s . c o m } if (!isLinkAlreadyLoaded(urlToLoad)) { addWebHead(urlToLoad, isFromAmp, isIncognito); } else if (!isForMinimized) { Toast.makeText(this, R.string.already_loaded, LENGTH_SHORT).show(); } }
From source file:com.mobicage.rogerthat.AbstractHomeActivity.java
private void processIntent(final Intent intent) { final String url = intent.getDataString(); if (intent.getBooleanExtra(INTENT_PROCESSED, false)) return;//from ww w . j av a 2 s . co m if (url != null) { goToMessagingActivity(); processUrl(url); } else if (intent.hasExtra(INTENT_KEY_LAUNCHINFO)) { String value = intent.getStringExtra(INTENT_KEY_LAUNCHINFO); if (INTENT_VALUE_SHOW_FRIENDS.equals(value)) { // goToUserFriendsActivity(); } else if (INTENT_VALUE_SHOW_MESSAGES.equals(value)) { goToMessagingActivity(); } else if (INTENT_VALUE_SHOW_NEW_MESSAGES.equals(value)) { if (intent.hasExtra(INTENT_KEY_MESSAGE)) { String messageKey = intent.getStringExtra(INTENT_KEY_MESSAGE); goToMessageDetail(messageKey); } else { goToMessagingActivity(); } } else if (INTENT_VALUE_SHOW_UPDATED_MESSAGES.equals(value)) { if (intent.hasExtra(INTENT_KEY_MESSAGE)) { String messageKey = intent.getStringExtra(INTENT_KEY_MESSAGE); goToMessageDetail(messageKey); } else { goToMessagingActivity(); } } else if (INTENT_VALUE_SHOW_SCANTAB.equals(value)) { goToScanActivity(); } else { L.bug("Unexpected (key, value) for HomeActivity intent: (" + INTENT_KEY_LAUNCHINFO + ", " + value + ")"); } if (mMessagingPlugin != null) { mMessagingPlugin.updateMessagesNotification(false, false, false); handleBadgeMessages(); } } intent.putExtra(INTENT_PROCESSED, true); }
From source file:com.synox.android.ui.activity.ShareActivity.java
@Override protected void onNewIntent(Intent intent) { // Verify the action and get the query if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); Log_OC.w(TAG, "Ignored Intent requesting to query for " + query); } else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) { Uri data = intent.getData();//from www. j av a2 s. c o m String dataString = intent.getDataString(); String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1); doShareWith(shareWith, UsersAndGroupsSearchProvider.DATA_GROUP.equals(data.getAuthority())); } else { Log_OC.wtf(TAG, "Unexpected intent " + intent.toString()); } }
From source file:com.cerema.cloud2.ui.activity.ShareActivity.java
@Override protected void onNewIntent(Intent intent) { // Verify the action and get the query if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); Log_OC.w(TAG, "Ignored Intent requesting to query for " + query); } else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) { Uri data = intent.getData();/*from w w w . ja va 2s .c o m*/ String dataString = intent.getDataString(); String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1); doShareWith(shareWith, data.getAuthority()); } else { Log_OC.wtf(TAG, "Unexpected intent " + intent.toString()); } }
From source file:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java
private void startPhoneZoom(Uri uri) { Log.e("Daniel", "---uri---" + uri); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); Log.e("Daniel", "--- intent.getDataString()---" + intent.getDataString()); Log.e("Daniel", "--- intent.getData()---" + intent.getData()); //???/*from ww w . j a v a 2s .c o m*/ intent.putExtra("corp", "true"); //? intent.putExtra("aspectY", 1); intent.putExtra("aspectX", 1); //? intent.putExtra("outputX", 150); intent.putExtra("outputY", 150); //? intent.putExtra("return-data", true); startActivityForResult(intent, RESULT_PHOTO); }
From source file:org.opendatakit.survey.android.activities.MediaCaptureAudioActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_CANCELED) { // request was canceled -- propagate setResult(Activity.RESULT_CANCELED); finish();// ww w. j av a 2s .c o m return; } Uri mediaUri = intent.getData(); // it is unclear whether getData() always returns a value or if // getDataString() does... String str = intent.getDataString(); if (mediaUri == null && str != null) { WebLogger.getLogger(appName).w(t, "Attempting to work around null mediaUri"); mediaUri = Uri.parse(str); } if (mediaUri == null) { // we are in trouble WebLogger.getLogger(appName).e(t, "No uri returned from RECORD_SOUND_ACTION!"); setResult(Activity.RESULT_CANCELED); finish(); return; } // Remove the current media. deleteMedia(); // get the file path and create a copy in the instance folder String binaryPath = MediaUtils.getPathFromUri(this, (Uri) mediaUri, Audio.Media.DATA); File source = new File(binaryPath); String extension = binaryPath.substring(binaryPath.lastIndexOf(".")); if (uriFragmentToMedia == null) { // use the newFileBase as a starting point... uriFragmentToMedia = uriFragmentNewFileBase + extension; } // adjust the mediaPath (destination) to have the same extension // and delete any existing file. File f = ODKFileUtils.getAsFile(appName, uriFragmentToMedia); File sourceMedia = new File(f.getParentFile(), f.getName().substring(0, f.getName().lastIndexOf('.')) + extension); uriFragmentToMedia = ODKFileUtils.asUriFragment(appName, sourceMedia); deleteMedia(); try { FileUtils.copyFile(source, sourceMedia); } catch (IOException e) { WebLogger.getLogger(appName).e(t, ERROR_COPY_FILE + sourceMedia.getAbsolutePath()); Toast.makeText(this, R.string.media_save_failed, Toast.LENGTH_SHORT).show(); deleteMedia(); setResult(Activity.RESULT_CANCELED); finish(); return; } if (sourceMedia.exists()) { // Add the copy to the content provier ContentValues values = new ContentValues(6); values.put(Audio.Media.TITLE, sourceMedia.getName()); values.put(Audio.Media.DISPLAY_NAME, sourceMedia.getName()); values.put(Audio.Media.DATE_ADDED, System.currentTimeMillis()); values.put(Audio.Media.DATA, sourceMedia.getAbsolutePath()); Uri MediaURI = getApplicationContext().getContentResolver().insert(Audio.Media.EXTERNAL_CONTENT_URI, values); WebLogger.getLogger(appName).i(t, "Inserting AUDIO returned uri = " + MediaURI.toString()); uriFragmentToMedia = ODKFileUtils.asUriFragment(appName, sourceMedia); WebLogger.getLogger(appName).i(t, "Setting current answer to " + sourceMedia.getAbsolutePath()); int delCount = getApplicationContext().getContentResolver().delete(mediaUri, null, null); WebLogger.getLogger(appName).i(t, "Deleting original capture of file: " + mediaUri.toString() + " count: " + delCount); } else { WebLogger.getLogger(appName).e(t, "Inserting Audio file FAILED"); } /* * We saved the audio to the instance directory. Verify that it is there... */ returnResult(); return; }