List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:com.schoentoon.connectbot.PubkeyListActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); switch (requestCode) { case REQUEST_CODE_PICK_FILE: if (resultCode == RESULT_OK && intent != null) { Uri uri = intent.getData();//from w w w. j a v a 2s . c o m try { if (uri != null) { readKeyFromFile(new File(URI.create(uri.toString()))); } else { String filename = intent.getDataString(); if (filename != null) readKeyFromFile(new File(URI.create(filename))); } } catch (IllegalArgumentException e) { Log.e(TAG, "Couldn't read from picked file", e); } } break; } }
From source file:com.zhongsou.souyue.activity.SplashActivity.java
/** * ?//from w ww . j a va2 s . com */ private void initFromWX() { Intent intent = this.getIntent(); if (null == intent) return; String str = intent.getDataString() == null ? "" : intent.getDataString(); try { if (ConfigApi.isSouyue()) { str = URLDecoder.decode(str, "utf-8"); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.i("", "splash : " + str); if ((ShareApi.WEIXIN_APP_ID.concat("://slot")).equals(str)) { jumpType = JUMP_TYPE_SLOT; Log.i("slot", "initFromWX"); return; } else if ((ShareApi.WEIXIN_APP_ID.concat("://zero")).equals(str)) { jumpType = JUMP_TYPE_ZERO; return; } else if (str.startsWith(ShareApi.WEIXIN_APP_ID + "://" + JUMP_TYPE_INTERESTCARD)) { jumpType = JUMP_TYPE_INTERESTCARD; CircleResponseResultItem item = new CircleResponseResultItem(); if (!ConfigApi.isSouyue()) { try { str = URLDecoder.decode(str, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } Uri uri = Uri.parse(str); if (uri != null) { String interest_id = uri.getQueryParameter("circleId"); try { item.setInterest_id(Long.valueOf(interest_id)); } catch (NumberFormatException e) { e.printStackTrace(); } pushInfo.setInterestBlog(item); } return; } else if (str.startsWith(ShareApi.WEIXIN_APP_ID.concat("://lingpai"))) { jumpType = JUMP_TYPE_LINGPAI; url = str.substring(str.indexOf("http"), str.length()); return; } else if (str.startsWith((ShareApi.WEIXIN_APP_ID.concat("://interest")))) { jumpType = JUMP_TYPE_INTEREST; if (!ConfigApi.isSouyue()) { try { str = URLDecoder.decode(str, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } wrapInterest(str); return; } else if (str.startsWith((ShareApi.WEIXIN_APP_ID.concat("://galleryNews")))) {// jumpType = JUMP_TYPE_GALLERYNEWS; String wxStr = ShareApi.WEIXIN_APP_ID.concat("://galleryNews"); str = str.substring(0, wxStr.length()) + "?" + str.substring(wxStr.length() + 1); wrapGalleryNews(str); return; } String[] st = str.split("//");// wx360a9785675a8653:// Log.i(LOG_TAG, str); if (st.length >= 2) { if (st.length == 3 && isMatchUrl(st[2], "opentype=(\\w{8})", "emptyWeb") && isMatchUrl(st[2], "source=(\\w{6})", "search")) {//?? String[] resultStr = st[2].split("\\?"); String[] param = resultStr[1].split("&"); for (int i = 0; i < param.length; i++) { String[] s = param[i].split("="); if (s.length >= 2) { if ("opentype".equals(s[0]) && "emptyWeb".equals(s[1])) { keyword = s[1];//keyword } if ("source".equals(s[0]) && "search".equals(s[1])) { srpId = s[1];//srpId?? } } } if (str.contains("url=")) { if (str.indexOf("url=") + 4 < str.length()) { url = str.substring(str.indexOf("url=") + 4, str.length()); } Log.i("", "url : " + url); } return; } if (!ConfigApi.isSouyue()) { try { st[1] = URLDecoder.decode(st[1], "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } String[] dataStr = st[1].split("&");// keyword=ddd&srpId=sfsfsf&url= if (dataStr.length >= 3) { String[] s = dataStr[0].split("="); if (s.length >= 2) keyword = s[1]; s = dataStr[1].split("="); if (s.length >= 2) srpId = s[1]; if (!ConfigApi.isSouyue()) { try { str = URLDecoder.decode(str, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } if (str.contains("&url=")) { if (str.indexOf("&url=") + 5 < str.length()) { url = str.substring(str.indexOf("&url=") + 5, str.length()); if (!ConfigApi.isSouyue()) { try { url = URLDecoder.decode(url, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } // add by trade if (url.contains("opentype=src")) { g = "0"; if (url.contains("md5")) { md5 = (url.split("md5=")[1]).split("&")[0]; } } } Log.i("", "url : " + url); } } else if (dataStr.length >= 2) { String[] s = dataStr[0].split("="); if (s.length >= 2) keyword = s[1]; s = dataStr[1].split("="); if (s.length >= 2) srpId = s[1]; } else { String[] s = dataStr[0].split("="); if (s.length >= 2) keyword = s[1]; } } else { pushInfo = null; } }
From source file:com.purchasingpower.inappbrowser.WebViewActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) { super.onActivityResult(requestCode, resultCode, data); return; }/*from w w w . j av a 2s.c om*/ Uri[] results = null; // Check that the response is a good one if (resultCode == Activity.RESULT_OK) { if (data == null) { // If there is not data, then we may have taken a photo if (mCameraPhotoPath != null) { results = new Uri[] { Uri.parse(mCameraPhotoPath) }; } } else { String dataString = data.getDataString(); if (dataString != null) { results = new Uri[] { Uri.parse(dataString) }; } } } mFilePathCallback.onReceiveValue(results); mFilePathCallback = null; } else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { if (requestCode != FILECHOOSER_RESULTCODE || mUploadMessage == null) { super.onActivityResult(requestCode, resultCode, data); return; } if (requestCode == FILECHOOSER_RESULTCODE) { if (null == this.mUploadMessage) { return; } Uri result = null; try { if (resultCode != RESULT_OK) { result = null; } else { // retrieve from the private variable if the intent is null result = data == null ? mCapturedImageURI : data.getData(); } } catch (Exception e) { Toast.makeText(getApplicationContext(), "activity :" + e, Toast.LENGTH_LONG).show(); } mUploadMessage.onReceiveValue(result); mUploadMessage = null; } } return; }
From source file:com.mobicage.rogerthat.plugins.messaging.MessagingActivity.java
private void processIntent(Intent intent, Boolean start) { if (intent != null) { final String intentAction = intent.getAction(); if (MainActivity.ACTION_NOTIFICATION_MESSAGE_RECEIVED.equals(intentAction)) { processMessageUpdatesIntent(intent); } else {//from w w w . java2s. c om final String url = intent.getDataString(); if (url != null) { processUrl(url); } if (start) { Bundle extras = intent.getExtras(); if (extras != null) { mMemberFilter = extras.getString(MessagingPlugin.MEMBER_FILTER); } } } } }
From source file:com.bitants.wally.activities.ImageDetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_details); setToolbar((Toolbar) findViewById(R.id.toolbar)); if (getToolbar() != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(Color.TRANSPARENT); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }//from w ww.j av a2 s . c om if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getToolbar().setPadding(0, getStatusBarHeight(), 0, 0); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(""); } final Intent intent = getIntent(); String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { pageUri = Uri.parse(intent.getDataString()); if ("wally".equalsIgnoreCase(pageUri.getScheme())) { pageUri = pageUri.buildUpon().scheme("http").build(); } } setupViews(); setupHandlers(); Size size = new Size(16, 9); if (intent.hasExtra(INTENT_EXTRA_IMAGE)) { final Image image = intent.getParcelableExtra(INTENT_EXTRA_IMAGE); final Bitmap thumbBitmap = WallyApplication.getBitmapThumb(); if (thumbBitmap != null) { size = fitToWidthAndKeepRatio(image.getWidth(), image.getHeight()); imageSize = size; photoView.getLayoutParams().width = size.getWidth(); photoView.getLayoutParams().height = size.getHeight(); Bitmap blurBitMap; try { blurBitMap = Blur.apply(imageHolder.getContext(), thumbBitmap); } catch (ArrayIndexOutOfBoundsException e) { //Blur couldn't be applied. Show regular thumbnail instead. blurBitMap = thumbBitmap; } photoView.setImageBitmap(blurBitMap); } } setupPaddings(size, false); if (savedInstanceState == null) { getPage(pageUri.toString()); } else if (savedInstanceState.containsKey(STATE_IMAGE_PAGE)) { imagePage = savedInstanceState.getParcelable(STATE_IMAGE_PAGE); } if (imagePage != null) { Message msgObj = uiHandler.obtainMessage(); msgObj.what = MSG_PAGE_FETCHED; msgObj.obj = imagePage; uiHandler.sendMessage(msgObj); } else { getPage(pageUri.toString()); } }
From source file:com.cerema.cloud2.files.InstantUploadBroadcastReceiver.java
private void handleNewVideoAction(Context context, Intent intent) { Cursor c = null;/*from ww w . j a v a 2 s.c om*/ String file_path = null; String file_name = null; String mime_type = null; Log_OC.w(TAG, "New video received"); if (!instantVideoUploadEnabled(context)) { Log_OC.d(TAG, "Instant video upload disabled, ignoring new video"); return; } Account account = AccountUtils.getCurrentOwnCloudAccount(context); if (account == null) { Log_OC.w(TAG, "No account found for instant upload, aborting"); return; } String[] CONTENT_PROJECTION = { Video.Media.DATA, Video.Media.DISPLAY_NAME, Video.Media.MIME_TYPE, Video.Media.SIZE }; c = context.getContentResolver().query(intent.getData(), CONTENT_PROJECTION, null, null, null); if (!c.moveToFirst()) { Log_OC.e(TAG, "Couldn't resolve given uri: " + intent.getDataString()); return; } file_path = c.getString(c.getColumnIndex(Video.Media.DATA)); file_name = c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME)); mime_type = c.getString(c.getColumnIndex(Video.Media.MIME_TYPE)); c.close(); Log_OC.d(TAG, file_path + ""); if (!isOnline(context) || (instantVideoUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) { return; } Intent i = new Intent(context, FileUploader.class); i.putExtra(FileUploader.KEY_ACCOUNT, account); i.putExtra(FileUploader.KEY_LOCAL_FILE, file_path); i.putExtra(FileUploader.KEY_REMOTE_FILE, FileStorageUtils.getInstantVideoUploadFilePath(context, file_name)); i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE); i.putExtra(FileUploader.KEY_MIME_TYPE, mime_type); i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true); // instant upload behaviour i = addInstantUploadBehaviour(i, context); context.startService(i); }
From source file:com.vuze.android.remote.activity.TorrentViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); AndroidUtilsUI.onCreate(this); super.onCreate(savedInstanceState); Intent intent = getIntent(); if (DEBUG) {/*from w w w . ja v a2 s. c om*/ Log.d(TAG, "TorrentViewActivity intent = " + intent); Log.d(TAG, "Type:" + intent.getType() + ";" + intent.getDataString()); } final Bundle extras = intent.getExtras(); if (extras == null) { Log.e(TAG, "No extras!"); finish(); return; } String remoteProfileID = extras.getString(SessionInfoManager.BUNDLE_KEY); if (remoteProfileID != null) { sessionInfo = SessionInfoManager.getSessionInfo(remoteProfileID, this); } if (sessionInfo == null) { Log.e(TAG, "sessionInfo NULL!"); finish(); return; } sessionInfo.addRpcAvailableListener(this); sessionInfo.addSessionSettingsChangedListeners(this); remoteProfile = sessionInfo.getRemoteProfile(); setContentView(R.layout.activity_torrent_view); setupActionBar(); // setup view ids now because listeners below may trigger as soon as we // get them tvUpSpeed = (TextView) findViewById(R.id.wvUpSpeed); tvDownSpeed = (TextView) findViewById(R.id.wvDnSpeed); tvCenter = (TextView) findViewById(R.id.wvCenter); toolbar = (Toolbar) findViewById(R.id.toolbar_bottom); setBottomToolbarEnabled(enableBottomToolbar); setSubtitle(remoteProfile.getNick()); boolean isLocalHost = remoteProfile.isLocalHost(); if (!VuzeRemoteApp.getNetworkState().isOnline() && !isLocalHost) { Resources resources = getResources(); String msg = resources.getString(R.string.no_network_connection); String reason = VuzeRemoteApp.getNetworkState().getOnlineStateReason(); if (reason != null) { msg += "\n\n" + reason; } AndroidUtils.showConnectionError(this, msg, false); return; } onCreate_setupDrawer(); }
From source file:com.shollmann.igcparser.ui.activity.FlightPreviewActivity.java
private void handleIntent() { Intent intent = getIntent(); if (intent.getExtras() != null) { fileToLoadPath = (String) getIntent().getExtras().get(Constants.FILE_TO_LOAD_PATH); }//from w w w . j a va 2 s .c o m String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { if (intent.getData() != null && Constants.App.CONTENT_URI.equalsIgnoreCase(intent.getData().getScheme())) { TrackerHelper.trackOpenGmailFlight(); new GetGmailAttachmentAsyncTask(this).execute(intent.getDataString()); } else { Uri uri = intent.getData(); fileToLoadPath = uri.getPath(); } } }
From source file:blackman.matt.infinitebrowser.InfinityBrowser.java
/** * Creates a board from an intent sent in. * * @param intent The intent to open a board. * @return The newly created board.//from w w w .j a v a 2 s .c om */ private Board loadFromIntent(Intent intent) { Board newBoard; String intentBoard = intent.getStringExtra(ARG_BOARD); String intentThread = intent.getStringExtra(ARG_THREAD); if (intentBoard != null) { if (intentThread == null) { newBoard = Board.newInstance(intentBoard); mTitle = "/" + intentBoard + "/"; } else { newBoard = Board.newInstance(intentBoard, intentThread); mTitle = "/" + intentBoard + "/" + intentThread + "/"; } } else { Pattern patternRoot = Pattern.compile("(?<=8chan.co\\/)\\w*"); Pattern patternThread = Pattern.compile("(?<=\\/res\\/)\\w*"); Pattern patternPost = Pattern.compile("(?<=#|#[qQ])\\d*$"); Matcher rootMatch = patternRoot.matcher(intent.getDataString()); Matcher threadMatch = patternThread.matcher(intent.getDataString()); Matcher postMatcher = patternPost.matcher(intent.getDataString()); rootMatch.find(); String boardRoot = rootMatch.group(0); if (threadMatch.find()) { if (postMatcher.find()) { newBoard = Board.newInstance(boardRoot, threadMatch.group(0), postMatcher.group(0)); } else { newBoard = Board.newInstance(boardRoot, threadMatch.group(0)); } } else { newBoard = Board.newInstance(boardRoot); } mTitle = intent.getDataString().replace("https://8chan.co", "").replace("http://8chan.co", "") .replace("index.html", ""); } return newBoard; }
From source file:com.andreadec.musicplayer.MainActivity.java
private void loadSongFromIntent() { Intent intent = getIntent(); if (intent != null && intent.getAction() == Intent.ACTION_VIEW) { try {// w w w. ja v a 2 s . c om intentFile = URLDecoder.decode(intent.getDataString(), "UTF-8"); intentFile = intentFile.replace("file://", ""); } catch (Exception e) { } } }