List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:com.slarker.tech.hi0734.view.widget.webview.AdvancedWebView.java
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { if (requestCode == mRequestCodeFilePicker) { if (resultCode == Activity.RESULT_OK) { if (intent != null) { if (mFileUploadCallbackFirst != null) { mFileUploadCallbackFirst.onReceiveValue(intent.getData()); mFileUploadCallbackFirst = null; } else if (mFileUploadCallbackSecond != null) { Uri[] dataUris = null; try { if (intent.getDataString() != null) { dataUris = new Uri[] { Uri.parse(intent.getDataString()) }; } else { if (Build.VERSION.SDK_INT >= 16) { if (intent.getClipData() != null) { final int numSelectedFiles = intent.getClipData().getItemCount(); dataUris = new Uri[numSelectedFiles]; for (int i = 0; i < numSelectedFiles; i++) { dataUris[i] = intent.getClipData().getItemAt(i).getUri(); }/*from ww w .j a v a 2s . c om*/ } } } } catch (Exception ignored) { } mFileUploadCallbackSecond.onReceiveValue(dataUris); mFileUploadCallbackSecond = null; } } } else { if (mFileUploadCallbackFirst != null) { mFileUploadCallbackFirst.onReceiveValue(null); mFileUploadCallbackFirst = null; } else if (mFileUploadCallbackSecond != null) { mFileUploadCallbackSecond.onReceiveValue(null); mFileUploadCallbackSecond = null; } } } }
From source file:com.creativtrendz.folio.ui.FolioWebViewScroll.java
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { if (requestCode == mRequestCodeFilePicker) { if (resultCode == Activity.RESULT_OK) { if (intent != null) { if (mFileUploadCallbackFirst != null) { mFileUploadCallbackFirst.onReceiveValue(intent.getData()); mFileUploadCallbackFirst = null; } else if (mFileUploadCallbackSecond != null) { Uri[] dataUris;//from w w w . jav a 2 s .com try { dataUris = new Uri[] { Uri.parse(intent.getDataString()) }; } catch (Exception e) { dataUris = null; } mFileUploadCallbackSecond.onReceiveValue(dataUris); mFileUploadCallbackSecond = null; } } } else { if (mFileUploadCallbackFirst != null) { mFileUploadCallbackFirst.onReceiveValue(null); mFileUploadCallbackFirst = null; } else if (mFileUploadCallbackSecond != null) { mFileUploadCallbackSecond.onReceiveValue(null); mFileUploadCallbackSecond = null; } } } }
From source file:com.geecko.QuickLyric.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String action = intent.getAction(); String extra = intent.getStringExtra(Intent.EXTRA_TEXT); if (action != null) { switch (action) { case NfcAdapter.ACTION_NDEF_DISCOVERED: Lyrics receivedLyrics = getBeamedLyrics(intent); if (receivedLyrics != null) updateLyricsFragment(0, 0, false, receivedLyrics); break; case "android.intent.action.SEARCH": search(intent.getStringExtra(SearchManager.QUERY)); break; case "android.intent.action.SEND": LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) getFragmentManager() .findFragmentByTag(LYRICS_FRAGMENT_TAG); new IdDecoder(this, lyricsViewFragment).execute(getIdUrl(extra)); selectItem(0);/* w w w . j a va2 s .co m*/ break; case "android.intent.action.VIEW": if (intent.getDataString().contains("spotify")) Spotify.onCallback(intent, this); break; case "com.geecko.QuickLyric.getLyrics": String[] metadata = intent.getStringArrayExtra("TAGS"); if (metadata != null) { String artist = metadata[0]; String track = metadata[1]; LyricsViewFragment lyricsFragment = (LyricsViewFragment) getFragmentManager() .findFragmentByTag(LYRICS_FRAGMENT_TAG); lyricsFragment.fetchLyrics(artist, track); selectItem(0); } break; case "com.geecko.QuickLyric.updateDBList": updateDBList(); break; } } }
From source file:com.zhihuigu.sosoOffice.RegisterThirdActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != RESULT_OK) { // RESULT_OK Log.e(TAG, "ActivityResult resultCode error"); return;/*from ww w . j a v a2 s . c o m*/ } Bitmap bm = null; // ContentProvider ContentResolver ContentResolver resolver = getContentResolver(); // Activity if (requestCode == IMAGE_CODE) {// String imgPath = ""; Uri originalUri = data.getData(); // uri // bm = MediaStore.Images.Media.getBitmap(resolver, originalUri); // bitmap // String[] proj = { MediaStore.Images.Media.DATA }; // androidAndroid Cursor cursor = managedQuery(originalUri, proj, null, null, null); // InputStream inputStream = resolver.openInputStream(originalUri); // if (cursor == null) { imgPath = data.getDataString(); } else { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); // cursor.moveToFirst(); // www.2cto.com imgPath = cursor.getString(column_index); } File fromFile = new File(imgPath); // if (fromFile != null && fromFile.exists()) { fileName = CommonUtils.getFileName();// File file = new File(SDCARD_ROOT_PATH + SAVE_PATH_IN_SDCARD); if (!file.exists()) { file.mkdirs(); } sdcardTempFile = new File(SDCARD_ROOT_PATH + SAVE_PATH_IN_SDCARD, fileName); // path = sdcardTempFile.getAbsolutePath(); // FileCopyUtil.copyfile(fromFile, sdcardTempFile, true); Bitmap bitmap = CommonUtils.getDrawable(fromFile.getAbsolutePath(), MyApplication.getInstance(this).getScreenWidth(), MyApplication.getInstance(this).getScreenHeight()); if (bitmap != null) { bitmap = CommonUtils.RotateImg(fromFile.getAbsolutePath(), bitmap);//90 boolean copy = CommonUtils.OutPutImage(sdcardTempFile, bitmap); if (copy) { /*File oldFile = new File(path); oldFile.delete();*/ path = sdcardTempFile.getAbsolutePath(); } } else { Toast.makeText(this, "", 3000).show(); } } bm = CommonUtils.getDrawable(path, photoView); if (bm != null) { photo_tag = true; bottomLinear.setVisibility(View.GONE); photoView.setImageBitmap(bm); } else { Toast.makeText(this, "", 3000).show(); } } else if (requestCode == REQUEST_CODE_TAKE_PICTURE) {// fileName = CommonUtils.getFileName();// File file = new File(SDCARD_ROOT_PATH + SAVE_PATH_IN_SDCARD); if (!file.exists()) { file.mkdirs(); } sdcardTempFile = new File(SDCARD_ROOT_PATH + SAVE_PATH_IN_SDCARD, fileName); if (CommonUtils.isHasSdcard()) {// path = SDCARD_ROOT_PATH + SAVE_PATH_IN_SDCARD + MyApplication.getInstance(this).getFileName(); Bitmap bitmap = CommonUtils.getDrawable(path, 500, 500); bitmap = CommonUtils.RotateImg(path, bitmap);//90 boolean copy = CommonUtils.OutPutImage(sdcardTempFile, bitmap); if (copy) { File oldFile = new File(path); oldFile.delete(); path = sdcardTempFile.getAbsolutePath(); } bm = CommonUtils.getDrawable(path, photoView); photo_tag = true; bottomLinear.setVisibility(View.GONE); photoView.setImageBitmap(bm); } else { // Bundle extras = data.getExtras(); bm = (Bitmap) extras.get("data"); photo_tag = true; bottomLinear.setVisibility(View.GONE); photoView.setImageBitmap(bm); } } }
From source file:aarddict.android.ArticleViewActivity.java
@Override void onDictionaryServiceReady() { if (this.backItems.isEmpty()) { final Intent intent = getIntent(); if (intent != null && intent.getAction() != null) { String action = intent.getAction(); String _word = null;/*from w w w . j av a 2 s. c om*/ if (action.equals(Intent.ACTION_SEARCH)) { _word = intent.getStringExtra("query"); } else if (action.equals(Intent.ACTION_SEND)) { _word = intent.getStringExtra(Intent.EXTRA_TEXT); } final String word = _word; if (word != null) { if (currentTask != null) { currentTask.cancel(); } currentTask = new TimerTask() { @Override public void run() { setProgress(500); String currentWord = word; Log.d(TAG, "intent.getDataString(): " + intent.getDataString()); while (currentWord.length() > 0) { Iterator<Entry> results = dictionaryService.lookup(currentWord); Log.d(TAG, "Looked up " + word); if (results.hasNext()) { currentTask = null; Entry entry = results.next(); showArticle(entry); break; } else { currentWord = currentWord.substring(0, currentWord.length() - 1); } } if (currentWord.length() == 0) { onSearchRequested(); } } }; try { timer.schedule(currentTask, 0); } catch (Exception e) { Log.d(TAG, "Failed to schedule task", e); showError(getString(R.string.msgErrorLoadingArticle, word)); } } } else { String word = intent.getStringExtra("word"); String section = intent.getStringExtra("section"); String volumeId = intent.getStringExtra("volumeId"); long articlePointer = intent.getLongExtra("articlePointer", -1); dictionaryService.setPreferred(volumeId); showArticle(volumeId, articlePointer, word, section); } } else { showCurrentArticle(); } }
From source file:pt.aptoide.backupapps.Aptoide.java
private void handleIncomingIntent(Intent incomingIntent) { if (incomingIntent.getData() != null) { AptoideLog.d(this, "received intent: " + incomingIntent.getDataString()); if (incomingIntent.getType() != null && incomingIntent.getType().equals(Constants.MIMETYPE_MYAPP)) { AptoideLog.d(this, "received myapp: " + incomingIntent.getDataString()); try { serviceDataCaller.callReceiveMyapp(incomingIntent.getDataString()); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace();/*from w w w .jav a 2s . co m*/ } } else if (incomingIntent.getScheme().equals(Constants.SCHEME_MARKET) || (incomingIntent.getScheme().equals(Constants.SCHEME_HTTPS) && incomingIntent.getData().getHost().equals(Constants.HOST_MARKET))) { String query = incomingIntent.getData().getQuery().split("&")[0].split("=")[1]; if (query.contains(":")) { query = query.split(":")[1]; } AptoideLog.d(this, "received market query: " + query); if (!synchronizingInstalledApps.get()) { startSearch(query, false, null, false); } else { blockedSearchQuery = query; } } cleanAptoideIntent(); } }
From source file:dentex.youtube.downloader.ShareActivity.java
void handleSendText(Intent intent, String action) throws IOException { ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { String sharedText = null; if (action.equals(Intent.ACTION_SEND)) { sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); } else if (action.equals(Intent.ACTION_VIEW)) { sharedText = intent.getDataString(); }/*from w w w .j a va 2s . c o m*/ if (sharedText != null) { if (linkValidator(sharedText) == "not_a_valid_youtube_link") { badOrNullLinkAlert(); } else if (sharedText != null) { showGeneralInfoTutorial(); asyncDownload = new AsyncDownload(); asyncDownload.execute(validatedLink); } } else { badOrNullLinkAlert(); } } else { progressBar1.setVisibility(View.GONE); tv.setText(getString(R.string.no_net)); PopUps.showPopUp(getString(R.string.no_net), getString(R.string.no_net_dialog_msg), "alert", this); Button retry = (Button) findViewById(R.id.share_activity_retry_button); retry.setVisibility(View.VISIBLE); retry.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Utils.reload(ShareActivity.this); } }); } }
From source file:com.becapps.easydownloader.ShareActivity.java
void handleSendText(Intent intent, String action) throws IOException { ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { String sharedText = null; if (action.equals(Intent.ACTION_SEND)) { sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); } else if (action.equals(Intent.ACTION_VIEW)) { sharedText = intent.getDataString(); }// w w w .java 2 s .c om if (sharedText != null) { if (linkValidator(sharedText) == "not_a_valid_video_link") { badOrNullLinkAlert(); } else if (sharedText != null) { showGeneralInfoTutorial(); asyncDownload = new AsyncDownload(); asyncDownload.execute(validatedLink); } } else { badOrNullLinkAlert(); } } else { progressBar1.setVisibility(View.GONE); tv.setText(getString(R.string.no_net)); PopUps.showPopUp(getString(R.string.no_net), getString(R.string.no_net_dialog_msg), "alert", this); Button retry = (Button) findViewById(R.id.share_activity_retry_button); retry.setVisibility(View.VISIBLE); retry.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Utils.reload(ShareActivity.this); } }); } }
From source file:org.videolan.vlc.gui.video.VideoPlayerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (data == null) return;/* ww w.j av a2 s. co m*/ if (data.getDataString() == null) { Log.d(TAG, "Subtitle selection dialog was cancelled"); } if (data.getData() == null) return; String uri = data.getData().getPath(); mSubtitleSelectedFiles.add(data.getData().getPath()); }
From source file:org.transdroid.core.gui.TorrentsActivity.java
@Background @OnActivityResult(FilePickerHelper.ACTIVITY_FILEPICKER) public void onFilePicked(int resultCode, Intent data) { // We should have received an Intent with a local torrent's Uri as data from the file picker if (data != null && data.getData() != null && !data.getData().toString().equals("")) { Uri dataUri = data.getData();/*from w w w . ja va2 s.c o m*/ // Get torrent title String title = NavigationHelper.extractNameFromUri(dataUri); // Adding a torrent from the via a content:// scheme (access through content provider stream) if (dataUri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) { addTorrentFromDownloads(dataUri, title); return; } // Adding a .torrent file directly via the file:// scheme (we can access it directly) if (dataUri.getScheme().equals("file")) { addTorrentByFile(data.getDataString(), title); } } }