List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:org.smssecure.smssecure.ConversationActivity.java
@Override public void startActivity(Intent intent) { try {//ww w . j a v a2 s . co m if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) { intent.removeExtra(Browser.EXTRA_APPLICATION_ID); } super.startActivity(intent); Log.d(TAG, "Opened link: " + intent.getDataString()); } catch (ActivityNotFoundException anfe) { Log.w(TAG, "No app found to view the link '" + intent.getDataString() + "', ignoring..."); Toast.makeText(this, R.string.ConversationActivity_cant_open_link, Toast.LENGTH_SHORT).show(); } }
From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). This is // necessary because we don't // want to open the camera driver and measure the screen size if we're // going to show the help on // first launch. That led to bugs where the scanning rectangle was the // wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null;// w ww.j a v a 2 s . com lastResult = null; resetStatusView(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } beepManager.updatePrefs(); inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { // Scan only products and send the result to mobile Product // Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM); returnRaw = inputUri.getQueryParameter(RAW_PARAM) != null; decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }
From source file:com.lgallardo.qbittorrentclient.RSSFeedActivity.java
private void handleIntent(Intent intent) { // Log.d("Debug", "RSSFeedActivity - handleIntent "); if (intent != null) { // Log.d("Debug", "RSSFeedActivity - intent is not null "); // Get package name packageName = "com.lgallardo.qbittorrentclient"; // Get package info PackageInfo pInfo = null;//w ww . j a v a 2 s .com try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); packageName = pInfo.packageName; } catch (PackageManager.NameNotFoundException e) { } // Log.d("Debug", "RSSFeedActivity - packageName: " + packageName); // Get theme UI preference from preferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); builderPrefs = new StringBuilder(); builderPrefs.append("\n" + sharedPrefs.getString("language", "NULL")); dark_ui = sharedPrefs.getBoolean("dark_ui", false); // Add Rss from url String rssUrl = intent.getDataString(); if (rssUrl != null) { RSSChannelInfoTask rssInfoTask = new RSSChannelInfoTask(); rssInfoTask.execute(rssUrl); } else { new rssFeedsTask().execute(); } } }
From source file:com.github.dfa.diaspora_android.activity.MainActivity.java
/** * Handle intents and execute intent specific actions * * @param intent intent to get handled/*from w ww . ja v a2 s .c om*/ */ private void handleIntent(Intent intent) { AppLog.i(this, "handleIntent()"); if (intent == null) { AppLog.v(this, "Intent was null"); return; } String action = intent.getAction(); String type = intent.getType(); String loadUrl = null; AppLog.v(this, "Action: " + action + " Type: " + type); if (Intent.ACTION_MAIN.equals(action)) { loadUrl = urls.getStreamUrl(); } else if (ACTION_OPEN_URL.equals(action)) { loadUrl = intent.getStringExtra(URL_MESSAGE); } else if (Intent.ACTION_VIEW.equals(action) && intent.getDataString() != null) { Uri data = intent.getData(); if (data != null && data.toString().startsWith(CONTENT_HASHTAG)) { handleHashtag(intent); return; } else { loadUrl = intent.getDataString(); AppLog.v(this, "Intent has a delicious URL for us: " + loadUrl); } } else if (ACTION_CHANGE_ACCOUNT.equals(action)) { AppLog.v(this, "Reset pod data and show PodSelectionFragment"); appSettings.setPod(null); runOnUiThread(new Runnable() { public void run() { navheaderTitle.setText(R.string.app_name); navheaderDescription.setText(R.string.app_subtitle); navheaderImage.setImageResource(R.drawable.ic_launcher); app.resetPodData( ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView()); } }); showFragment(getFragment(PodSelectionFragment.TAG)); } else if (ACTION_CLEAR_CACHE.equals(action)) { AppLog.v(this, "Clear WebView cache"); runOnUiThread(new Runnable() { public void run() { ContextMenuWebView wv = ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)) .getWebView(); if (wv != null) { wv.clearCache(true); } } }); } else if (Intent.ACTION_SEND.equals(action) && type != null) { switch (type) { case "text/plain": if (intent.hasExtra(Intent.EXTRA_SUBJECT)) { handleSendSubject(intent); } else { handleSendText(intent); } break; case "image/*": handleSendImage(intent); //TODO: Add intent filter to Manifest and implement method break; } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { /* TODO: Implement and add filter to manifest */ return; } //Catch split screen recreation if (action != null && action.equals(Intent.ACTION_MAIN) && getTopFragment() != null) { return; } if (loadUrl != null) { navDrawer.closeDrawers(); openDiasporaUrl(loadUrl); } }
From source file:de.baumann.browser.Browser.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Uri[] results = null;/*from ww w . j av a 2 s . c o m*/ // 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; }
From source file:org.fdroid.fdroid.AppDetails.java
private void tryOpenUri(String s) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s)); if (intent.resolveActivity(packageManager) == null) { Toast.makeText(this, getString(R.string.no_handler_app, intent.getDataString()), Toast.LENGTH_LONG) .show();/*from www.ja v a2 s . c o m*/ return; } startActivity(intent); }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String data = intent.getDataString(); String action = intent.getAction(); if (data != null && data.startsWith("x-ubuntuone-sso")) { validate();//from w ww . ja v a2 s . co m } else if (ACTION_PICK_AUTO_UPLOAD_DIRECTORY.equals(action)) { mIsPickAutoUploadDirectoryMode = true; showDialog(DIALOG_PICK_UPLOAD_DIRECTORY_ID); } }
From source file:de.baumann.hhsmoodle.fragmentsMain.FragmentBrowser.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RESULT_CODE_ICE_CREAM: sharedPref.edit().putString("load_next", "false").apply(); Uri uri = null;// w w w . j a v a 2s . c om if (data != null) { uri = data.getData(); } mUploadMessage.onReceiveValue(uri); mUploadMessage = null; new Handler().postDelayed(new Runnable() { public void run() { sharedPref.edit().putString("load_next", "true").apply(); } }, 1500); break; case REQUEST_CODE_LOLLIPOP: sharedPref.edit().putString("load_next", "false").apply(); 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; new Handler().postDelayed(new Runnable() { public void run() { sharedPref.edit().putString("load_next", "true").apply(); } }, 1500); break; } }
From source file:com.jtechme.apphub.AppDetailsData.java
private void tryOpenUri(String s) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s)); if (intent.resolveActivity(mPm) == null) { Toast.makeText(this, getString(R.string.no_handler_app, intent.getDataString()), Toast.LENGTH_LONG) .show();/* w w w . ja va 2s . c om*/ return; } startActivity(intent); }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mTracker = GoogleAnalyticsTracker.getInstance(); mTracker.start(Analytics.U1F_ACCOUNT, this); mTracker.trackPageView(TAG);// w w w . j a v a 2 s .c o m mHandler = new Handler(); mReceiver = new DetachableResultReceiver(mHandler); mSignOutReceiver = new SignOutBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter("com.ubuntuone.android.files.SIGN_OUT"); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this); lbm.registerReceiver(mSignOutReceiver, intentFilter); mResolver = getContentResolver(); // Override splash screen background. getWindow().setBackgroundDrawableResource(android.R.drawable.screen_background_light); final ImageButton homeButton = (ImageButton) getActionBar().findViewById(R.id.gd_action_bar_home_item); homeButton.setImageResource(R.drawable.u1_logo); // Refresh addActionBarItem(Type.Refresh); mLoaderItem = (LoaderActionBarItem) getActionBar().getItem(ActionBar.REFRESH); mLoaderItem.setDrawable(R.drawable.ic_act_action_bar_refresh); // Upload addActionBarItem(Type.Add); mUploadItem = (NormalActionBarItem) getActionBar().getItem(ActionBar.UPLOAD); mUploadItem.setDrawable(R.drawable.ic_act_action_bar_add); onCreateUploadQuickActionGrid(); getActionBar().setBackgroundResource(R.drawable.action_bar_background); mEmptyTextView = (TextView) findViewById(android.R.id.empty); ListView listView = getListView(); listView.setEmptyView(mEmptyTextView); listView.setFastScrollEnabled(true); registerForContextMenu(getListView()); mPathTracker = new PathTracker(); if (NetworkUtil.getAvailableNetworkType(this) == -1) { UIUtil.showToast(this, R.string.toast_working_offline, true); } if (Preferences.hasTokens(this)) { mImageDownloader = U1CroppedImageDownloader.SMALL; onRefresh(null); suggestAutoUploadConfiguration(); ChangeLogUtils.maybeShowChangelog(this); } else { final Intent intent = getIntent(); final String data = (intent != null) ? intent.getDataString() : null; if (data != null && data.startsWith("x-ubuntuone-sso")) { validate(); } else { signIn(); } } String action = getIntent() != null ? getIntent().getAction() : null; if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { mIsPickShareWithDirectoryMode = true; shareIntent = getIntent(); showDialog(DIALOG_PICK_UPLOAD_DIRECTORY_ID); } }