List of usage examples for android.content Intent getBundleExtra
public Bundle getBundleExtra(String name)
From source file:me.trashout.activity.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Log.d(TAG, "onNewIntent: "); if (intent.getStringExtra(EXTRA_FRAGMENT_NAME) != null) { Fragment currentFragment = getCurrentFragment(); if (!(currentFragment != null && currentFragment.getTag().equalsIgnoreCase(intent.getStringExtra(EXTRA_FRAGMENT_NAME)))) { Bundle args = intent.getBundleExtra(EXTRA_ARGUMENTS); Fragment fragment = instantiateFragment(intent.getStringExtra(EXTRA_FRAGMENT_NAME)); if (args != null) { fragment.setArguments(args); }// w ww .j ava2 s. c o m replaceFragment(fragment); } } }
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private void handleManager(Context context, Intent intent, String action) { if (PreventIntent.ACTION_GET_PACKAGES.equals(action)) { handleGetPackages(action);/*from w ww . j a v a 2 s. c om*/ } else if (PreventIntent.ACTION_GET_PROCESSES.equals(action)) { handleGetProcesses(context, action); } else if (PreventIntent.ACTION_GET_INFO.equals(action)) { handleGetInfo(); } else if (PreventIntent.ACTION_UPDATE_PREVENT.equals(action)) { handleUpdatePrevent(action, intent); } else if (PreventIntent.ACTION_SYSTEM_LOG.equals(action)) { sendLogAsync(); } else if (PreventIntent.ACTION_UPDATE_CONFIGURATION.equals(action)) { handleConfiguration(intent.getBundleExtra(PreventIntent.EXTRA_CONFIGURATION)); } else if (PreventIntent.ACTION_CHECK_LICENSE.equals(action)) { handleCheckLicense(context, intent); } else if (PreventIntent.ACTION_SOFT_REBOOT.equals(action)) { softReboot(); } else if (PreventIntent.ACTION_REBOOT.equals(action)) { reboot(); } }
From source file:com.battlelancer.seriesguide.api.SeriesGuideExtension.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;//ww w. j ava2 s. c o m } String action = intent.getAction(); if (ACTION_SUBSCRIBE.equals(action)) { // just subscribing or unsubscribing handleSubscribe((ComponentName) intent.getParcelableExtra(EXTRA_SUBSCRIBER_COMPONENT), intent.getStringExtra(EXTRA_TOKEN)); } else if (ACTION_UPDATE.equals(action)) { // subscriber requests an updated action if (intent.hasExtra(EXTRA_ENTITY_IDENTIFIER) && intent.hasExtra(EXTRA_EPISODE)) { handleEpisodeRequest(intent.getIntExtra(EXTRA_ENTITY_IDENTIFIER, 0), intent.getBundleExtra(EXTRA_EPISODE)); } } }
From source file:se.leap.bitmaskclient.ProviderAPI.java
@Override protected void onHandleIntent(Intent command) { final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY); String action = command.getAction(); Bundle parameters = command.getBundleExtra(PARAMETERS); if (provider_api_url == null && preferences.contains(Provider.KEY)) { try {/*from w w w. j a v a 2s . c o m*/ JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); provider_api_url = provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION); go_ahead = true; } catch (JSONException e) { go_ahead = false; } } if (action.equalsIgnoreCase(SET_UP_PROVIDER)) { Bundle result = setUpProvider(parameters); if (go_ahead) { if (result.getBoolean(RESULT_KEY)) { receiver.send(PROVIDER_OK, result); } else { receiver.send(PROVIDER_NOK, result); } } } else if (action.equalsIgnoreCase(SIGN_UP)) { UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources); Bundle result = tryToRegister(parameters); if (result.getBoolean(RESULT_KEY)) { receiver.send(SUCCESSFUL_SIGNUP, result); } else { receiver.send(FAILED_SIGNUP, result); } } else if (action.equalsIgnoreCase(LOG_IN)) { UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources); Bundle result = tryToAuthenticate(parameters); if (result.getBoolean(RESULT_KEY)) { receiver.send(SUCCESSFUL_LOGIN, result); UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources); } else { receiver.send(FAILED_LOGIN, result); UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources); } } else if (action.equalsIgnoreCase(LOG_OUT)) { UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources); if (logOut()) { receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY); UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources); } else { receiver.send(LOGOUT_FAILED, Bundle.EMPTY); UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources); } } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) { if (updateVpnCertificate()) { receiver.send(CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY); } else { receiver.send(INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY); } } else if (action.equalsIgnoreCase(DOWNLOAD_EIP_SERVICE)) { Bundle result = getAndSetEipServiceJson(); if (result.getBoolean(RESULT_KEY)) { receiver.send(CORRECTLY_DOWNLOADED_EIP_SERVICE, result); } else { receiver.send(INCORRECTLY_DOWNLOADED_EIP_SERVICE, result); } } }
From source file:org.cobaltians.cobalt.activities.CobaltActivity.java
public void popTo(String controller, String page, JSONObject data) { Intent popToIntent = Cobalt.getInstance(this).getIntentForController(controller, page); if (popToIntent != null) { Bundle popToExtras = popToIntent.getBundleExtra(Cobalt.kExtras); String popToActivityClassName = popToExtras.getString(Cobalt.kActivity); try {/* w ww. j ava 2 s .c o m*/ Class<?> popToActivityClass = Class.forName(popToActivityClassName); boolean popToControllerFound = false; int popToControllerIndex = -1; for (int i = sActivitiesArrayList.size() - 1; i >= 0; i--) { Activity oldActivity = sActivitiesArrayList.get(i); Class<?> oldActivityClass = oldActivity.getClass(); Bundle oldBundle = oldActivity.getIntent().getExtras(); Bundle oldExtras = (oldBundle != null) ? oldBundle.getBundle(Cobalt.kExtras) : null; String oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; if (oldPage == null && CobaltActivity.class.isAssignableFrom(oldActivityClass)) { Fragment fragment = ((CobaltActivity) oldActivity).getSupportFragmentManager() .findFragmentById(((CobaltActivity) oldActivity).getFragmentContainerId()); if (fragment != null) { oldExtras = fragment.getArguments(); oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; } } if (popToActivityClass.equals(oldActivityClass) && (!CobaltActivity.class .isAssignableFrom(oldActivityClass) || (CobaltActivity.class.isAssignableFrom(oldActivityClass) && page.equals(oldPage)))) { popToControllerFound = true; popToControllerIndex = i; ((CobaltActivity) oldActivity).setDataNavigation(data); break; } } if (popToControllerFound) { while (popToControllerIndex + 1 < sActivitiesArrayList.size()) { sActivitiesArrayList.get(popToControllerIndex + 1).finish(); } } else if (Cobalt.DEBUG) Log.w(Cobalt.TAG, TAG + " - popTo: controller " + controller + (page == null ? "" : " with page " + page) + " not found in history. Abort."); } catch (ClassNotFoundException exception) { exception.printStackTrace(); } } else if (Cobalt.DEBUG) Log.e(Cobalt.TAG, TAG + " - popTo: unable to pop to null controller"); }
From source file:com.facebook.widget.FacebookDialog.java
static private String getEventName(Intent intent) { String action = intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_ACTION); boolean hasPhotos = intent.hasExtra(NativeProtocol.EXTRA_PHOTOS); boolean hasVideo = false; Bundle extras = intent.getBundleExtra(NativeProtocol.EXTRA_PROTOCOL_METHOD_ARGS); if (extras != null) { ArrayList<String> photo = extras.getStringArrayList(NativeProtocol.METHOD_ARGS_PHOTOS); String video = extras.getString(NativeProtocol.METHOD_ARGS_VIDEO); if (photo != null && !photo.isEmpty()) { hasPhotos = true;/*from w w w .ja v a 2s.c o m*/ } if (video != null && !video.isEmpty()) { hasVideo = true; } } return getEventName(action, hasPhotos, hasVideo); }
From source file:org.andstatus.app.msg.TimelineActivity.java
private void parseAppSearchData(Intent intentNew) { Bundle appSearchData = intentNew.getBundleExtra(SearchManager.APP_DATA); if (appSearchData == null || !mListParametersNew .parseUri(Uri.parse(appSearchData.getString(IntentExtra.TIMELINE_URI.key, "")))) { return;//w ww.ja v a2s .co m } /* The query itself is still from the Intent */ mListParametersNew.mSearchQuery = TimelineListParameters .notNullString(intentNew.getStringExtra(SearchManager.QUERY)); if (!TextUtils.isEmpty(mListParametersNew.mSearchQuery) && appSearchData.getBoolean(IntentExtra.GLOBAL_SEARCH.key, false)) { setSyncing("Global search: " + mListParametersNew.mSearchQuery, true); MyServiceManager .sendManualForegroundCommand( CommandData .searchCommand( isTimelineCombined() ? "" : MyContextHolder.get().persistentAccounts() .getCurrentAccountName(), mListParametersNew.mSearchQuery)); } }
From source file:com.hybris.mobile.lib.location.geofencing.service.GeofencingIntentService.java
/** * Handles incoming intents/* w w w. ja v a 2 s .c o m*/ * * @param intent The Intent sent by Location Services. This Intent is provided to Location Services (inside a * PendingIntent) when you call addGeofences() */ @Override protected void onHandleIntent(Intent intent) { Log.i(TAG, "Geofencing event received"); GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); // Check for errors if (geofencingEvent.hasError()) { Log.e(TAG, "Error with geofencing. Error Code: " + geofencingEvent.getErrorCode()); } else { // Get the type of transition (entry or leaving_geofence) int geofenceTransition = geofencingEvent.getGeofenceTransition(); Log.i(TAG, "Geofence transition type: " + geofenceTransition); // Test that a valid transition was reported if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER || geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { // Post a notification List<Geofence> geofences = geofencingEvent.getTriggeringGeofences(); if (geofences != null && !geofences.isEmpty()) { for (Geofence geofence : geofences) { Log.d(TAG, "Intent information: "); Bundle intentBundle = intent .getBundleExtra(GeofencingConstants.PREFIX_INTENT_BUNDLE + geofence.getRequestId()); if (intentBundle != null) { Log.d(TAG, "Bundle information: "); for (String key : intentBundle.keySet()) { Log.d(TAG, "Key: " + key + ". Value: " + intentBundle.get(key)); } sendNotification(geofence, (GeofenceObject.Notification) intentBundle.getParcelable( GeofencingConstants.PREFIX_INTENT_NOTIFICATION_TRANSITION + geofenceTransition), geofenceTransition); } else { Log.e(TAG, "No bundle found for geofence id " + geofence.getRequestId()); } } } else { Log.e(TAG, "No associated geofences found for transition " + geofenceTransition); } } else { // Log the error. Log.e(TAG, "Geofence transition not supported by the library. Details: " + geofenceTransition); } } }
From source file:com.folioreader.ui.folio.activity.FolioActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RequestCode.SEARCH.value) { Log.v(LOG_TAG, "-> onActivityResult -> " + RequestCode.SEARCH); if (resultCode == RESULT_CANCELED) return; searchAdapterDataBundle = data.getBundleExtra(SearchAdapter.DATA_BUNDLE); searchQuery = data.getCharSequenceExtra(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY); if (resultCode == SearchActivity.ResultCode.ITEM_SELECTED.getValue()) { searchItem = data.getParcelableExtra(EXTRA_SEARCH_ITEM); // In case if SearchActivity is recreated due to screen rotation then FolioActivity // will also be recreated, so mFolioPageViewPager might be null. if (mFolioPageViewPager == null) return; currentChapterIndex = getChapterIndex(Constants.HREF, searchItem.getHref()); mFolioPageViewPager.setCurrentItem(currentChapterIndex); FolioPageFragment folioPageFragment = getCurrentFragment(); if (folioPageFragment == null) return; folioPageFragment.highlightSearchItem(searchItem); searchItem = null;//from www . ja va 2 s . c om } } else if (requestCode == RequestCode.CONTENT_HIGHLIGHT.value && resultCode == RESULT_OK && data.hasExtra(TYPE)) { String type = data.getStringExtra(TYPE); if (type.equals(CHAPTER_SELECTED)) { goToChapter(data.getStringExtra(SELECTED_CHAPTER_POSITION)); } else if (type.equals(HIGHLIGHT_SELECTED)) { HighlightImpl highlightImpl = data.getParcelableExtra(HIGHLIGHT_ITEM); currentChapterIndex = highlightImpl.getPageNumber(); mFolioPageViewPager.setCurrentItem(currentChapterIndex); FolioPageFragment folioPageFragment = getCurrentFragment(); if (folioPageFragment == null) return; folioPageFragment.scrollToHighlightId(highlightImpl.getRangy()); } } }
From source file:org.jitsi.android.gui.DialogActivity.java
/** * {@inheritDoc}//from www.ja v a2s . co m */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); setContentView(R.layout.alert_dialog); View content = findViewById(android.R.id.content); // Title setTitle(intent.getStringExtra(EXTRA_TITLE)); // Message or custom content String contentFragment = intent.getStringExtra(EXTRA_CONTENT_FRAGMENT); if (contentFragment != null) { // Hide alert text ViewUtil.ensureVisible(content, R.id.alertText, false); // Display content fragment if (savedInstanceState == null) { try { // Instantiate content fragment Class contentClass = Class.forName(contentFragment); Fragment fragment = (Fragment) contentClass.newInstance(); // Set fragment arguments fragment.setArguments(intent.getBundleExtra(EXTRA_CONTENT_ARGS)); // Insert the fragment getSupportFragmentManager().beginTransaction().replace(R.id.alertContent, fragment).commit(); } catch (Exception e) { throw new RuntimeException(e); } } } else { ViewUtil.setTextViewValue(findViewById(android.R.id.content), R.id.alertText, intent.getStringExtra(EXTRA_MESSAGE)); } // Confirm button text String confirmTxt = intent.getStringExtra(EXTRA_CONFRIM_TXT); if (confirmTxt != null) { ViewUtil.setTextViewValue(content, R.id.okButton, confirmTxt); } // Show cancel button if confirm label is not null ViewUtil.ensureVisible(content, R.id.cancelButton, confirmTxt != null); // Sets the listener this.listenerID = intent.getLongExtra(EXTRA_LISTENER_ID, -1); if (listenerID != -1) { this.listener = listenersMap.get(listenerID); } this.cancelable = intent.getBooleanExtra(EXTRA_CANCELABLE, true); // Prevents from closing the dialog on outside touch setFinishOnTouchOutside(cancelable); // Removes the buttons if (intent.getBooleanExtra(EXTRA_REMOVE_BUTTONS, false)) { ViewUtil.ensureVisible(content, R.id.okButton, false); ViewUtil.ensureVisible(content, R.id.cancelButton, false); } // Close this dialog on ACTION_CLOSE_DIALOG broadcast long dialogId = intent.getLongExtra(EXTRA_DIALOG_ID, -1); if (dialogId != -1) { this.closeIntentListener = new CloseDialogListener(dialogId); registerReceiver(closeIntentListener, new IntentFilter(ACTION_CLOSE_DIALOG)); // Adds this dialog to active dialogs list and notifies all waiting // threads. synchronized (displayedDialogs) { displayedDialogs.add(dialogId); displayedDialogs.notifyAll(); } } }