List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:app.axe.imooc.zxing.app.CaptureActivity.java
@SuppressWarnings("deprecation") @Override//www .j av a2 s .c o m protected void onResume() { super.onResume(); resetStatusView(); 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. if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.CAMERA }, MY_PERMISSIONS_REQUEST_CAMERA); } else { initCamera(surfaceHolder); } } else { // Install the callback and wait for surfaceCreated() to init the // camera. Log.e("CaptureActivity", "onResume"); } Intent intent = getIntent(); String action = intent == null ? null : intent.getAction(); String dataString = intent == null ? null : intent.getDataString(); if (intent != null && action != null) { if (action.equals(Intents.Scan.ACTION)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = Source.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); } 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 = Source.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (dataString != null && dataString.startsWith(ZXING_URL)) { // 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 = Source.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } else { // Scan all formats and handle the results ourselves (launched // from Home). source = Source.NONE; decodeFormats = null; } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } else { source = Source.NONE; decodeFormats = null; characterSet = null; } beepManager.updatePrefs(); }
From source file:com.pkmmte.techdissected.activity.MainActivity.java
protected boolean handleIntent() { // Get the launch intent final Intent launchIntent = getIntent(); // Return false if intent is invalid if (launchIntent == null || launchIntent.getAction() == null) return false; // Handle intent appropriately if (launchIntent.getAction().equals(Intent.ACTION_VIEW)) { // Create ArticleActivity intent containing the received URL String Intent intent = new Intent(this, ArticleActivity.class); intent.putExtra(PkRSS.KEY_ARTICLE_URL, launchIntent.getDataString()); // Clear launch intent action & start article activity setIntent(launchIntent.setAction(null)); startActivity(intent);/*from www . j a va 2 s .c o m*/ // Return true to indicate we handled it return true; } // Nothing was done, return false return false; }
From source file:bolts.AppLinkTest.java
public void testSimpleAppLinkNavigationWithExtrasAndAppLinkDataFallBackToWeb() throws Exception { AppLink.Target target = new AppLink.Target(PACKAGE_NAME, "bolts.utils.BoltsActivity3", Uri.parse("bolts3://"), "Bolts"); AppLink appLink = new AppLink(Uri.parse("http://www.example.com/path"), Arrays.asList(target), Uri.parse("http://www.example.com/path")); Bundle extras = new Bundle(); extras.putString("foo", "bar1"); Bundle appLinkData = new Bundle(); appLinkData.putString("foo", "bar2"); AppLinkNavigation navigation = new AppLinkNavigation(appLink, extras, appLinkData); AppLinkNavigation.NavigationResult navigationType = navigation.navigate(activityInterceptor); assertEquals(AppLinkNavigation.NavigationResult.WEB, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertTrue(openedIntent.getDataString().startsWith("http://www.example.com/path")); String appLinkDataString = openedIntent.getData().getQueryParameter("al_applink_data"); JSONObject appLinkDataJSON = new JSONObject(appLinkDataString); JSONObject appLinkExtrasJSON = appLinkDataJSON.getJSONObject("extras"); assertEquals("bar1", appLinkExtrasJSON.getString("foo")); assertEquals("bar2", appLinkData.getString("foo")); }
From source file:com.github.dfa.diaspora_android.activity.ShareActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) { super.onActivityResult(requestCode, resultCode, data); return;/*from ww w . j a v a 2s .c om*/ } Uri[] results = null; if (resultCode == RESULT_OK) { if (data == null) { 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:com.openerp.addons.messages.MessageComposeActivty.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PICKFILE_RESULT_CODE: if (resultCode == RESULT_OK) { String FilePath = data.getDataString(); Uri fileUri = Uri.parse(FilePath); file_uris.add(fileUri);/* w ww . j a v a2 s . c o m*/ handleReceivedFile(); } break; } }
From source file:org.y20k.transistor.MainActivityFragment.java
private void handleNewStationIntent() { // get intent Intent intent = mActivity.getIntent(); // check for intent of tyoe VIEW if (Intent.ACTION_VIEW.equals(intent.getAction())) { // set new station URL String newStationURL;/*from w w w . ja v a2 s . co m*/ // mime type check if (intent.getType() != null && intent.getType().startsWith("audio/")) { newStationURL = intent.getDataString(); } // no mime type else { newStationURL = intent.getDataString(); } // clear the intent intent.setAction(""); // check for null if (newStationURL != null) { // download and add new station StationDownloader stationDownloader = new StationDownloader(newStationURL, mActivity); stationDownloader.execute(); // send local broadcast Intent i = new Intent(); i.setAction(ACTION_COLLECTION_CHANGED); LocalBroadcastManager.getInstance(mActivity).sendBroadcast(i); } // unsuccessful - log failure else { Log.v(LOG_TAG, "Received an empty intent"); } } }
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 w w w . j a va2 s . c o 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:com.stanleyidesis.quotograph.api.receiver.LWQReceiver.java
@Override public void onReceive(final Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { // Set the alarm LWQAlarmController.resetAlarm(); } else if (context.getString(R.string.action_change_wallpaper).equals(action)) { // Change the wallpaper Intent updateService = new Intent(context, LWQUpdateService.class); startWakefulService(context, updateService); LWQNotificationControllerHelper.get().dismissNewWallpaperNotification(); LWQNotificationControllerHelper.get().dismissWallpaperGenerationFailureNotification(); // Log either a skip or auto-generated wallpaper if (AnalyticsUtils.URI_CHANGE_SOURCE_NOTIFICATION.equalsIgnoreCase(intent.getDataString())) { AnalyticsUtils.trackEvent(AnalyticsUtils.CATEGORY_WALLPAPER, AnalyticsUtils.ACTION_SKIPPED, AnalyticsUtils.LABEL_FROM_NOTIF); } else if (AnalyticsUtils.URI_CHANGE_SOURCE_ALARM.equalsIgnoreCase(intent.getDataString())) { AnalyticsUtils.trackEvent(AnalyticsUtils.CATEGORY_WALLPAPER, AnalyticsUtils.ACTION_AUTOMATICALLY_GEN, AnalyticsUtils.LABEL_ALARM); }/*w ww.j av a2 s. c o m*/ } else if (context.getString(R.string.action_share).equals(action)) { final LWQWallpaperController wallpaperController = LWQWallpaperControllerHelper.get(); final String shareText = String.format("\"%s\" - %s", wallpaperController.getQuote(), wallpaperController.getAuthor()); final String shareTitle = String.format("Quote by %s", wallpaperController.getAuthor()); Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareTitle); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareText); final Intent chooser = Intent.createChooser(sharingIntent, context.getResources().getString(R.string.share_using)); chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(chooser); // Log it boolean sharedFromNotif = AnalyticsUtils.URI_SHARE_SOURCE_NOTIFICATION .equalsIgnoreCase(intent.getDataString()); AnalyticsUtils.trackShare(AnalyticsUtils.CATEGORY_WALLPAPER, sharedFromNotif ? AnalyticsUtils.LABEL_FROM_NOTIF : AnalyticsUtils.LABEL_IN_APP); } else if (context.getString(R.string.action_save).equals(action)) { AnalyticsUtils.trackEvent(AnalyticsUtils.CATEGORY_WALLPAPER, AnalyticsUtils.ACTION_SAVED, AnalyticsUtils.LABEL_FROM_NOTIF); new LWQSaveWallpaperImageTask().execute(); } else if (context.getString(R.string.action_survey_response).equals(action)) { LWQNotificationControllerHelper.get().dismissSurveyNotification(); int surveyResponse = Integer.parseInt(intent.getDataString()); if (surveyResponse < UserSurveyController.RESPONSE_NEVER || surveyResponse > UserSurveyController.RESPONSE_OKAY) { return; } UserSurveyController.handleResponse(surveyResponse); } }
From source file:org.getlantern.firetweet.fragment.support.MessagesConversationFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUEST_PICK_IMAGE: { if (resultCode != Activity.RESULT_OK || data.getDataString() == null) { break; }/*from w ww . j av a 2s . c om*/ mImageUri = data.getDataString(); updateAddImageButton(); break; } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.mobicage.rogerthat.plugins.messaging.MessagingActivity.java
private void processMessageUpdatesIntent(final Intent intent) { final String url = intent.getDataString(); if (intent.getBooleanExtra(HomeActivity.INTENT_PROCESSED, false)) return;// www . j a v a2 s.com if (url != null) { ActivityUtils.goToMessagingActivity(this, false, null); processUrl(url); } else if (intent.hasExtra(HomeActivity.INTENT_KEY_LAUNCHINFO)) { String value = intent.getStringExtra(HomeActivity.INTENT_KEY_LAUNCHINFO); if (HomeActivity.INTENT_VALUE_SHOW_FRIENDS.equals(value)) { // goToUserFriendsActivity(); } else if (HomeActivity.INTENT_VALUE_SHOW_MESSAGES.equals(value)) { ActivityUtils.goToMessagingActivity(this, false, null); } else if (HomeActivity.INTENT_VALUE_SHOW_NEW_MESSAGES.equals(value) || HomeActivity.INTENT_VALUE_SHOW_UPDATED_MESSAGES.equals(value)) { if (intent.hasExtra(HomeActivity.INTENT_KEY_MESSAGE)) { if (!App.getContext().getPinLockMgr().canContinueToActivity()) { mPendingIntent = intent; return; } String messageKey = intent.getStringExtra(HomeActivity.INTENT_KEY_MESSAGE); goToMessageDetail(messageKey); } else { ActivityUtils.goToMessagingActivity(this, false, null); } } else if (HomeActivity.INTENT_VALUE_SHOW_SCANTAB.equals(value)) { ActivityUtils.goToScanActivity(this, false, null); } else { L.bug("Unexpected (key, value) for HomeActivity intent: (" + HomeActivity.INTENT_KEY_LAUNCHINFO + ", " + value + ")"); } } intent.putExtra(HomeActivity.INTENT_PROCESSED, true); }