List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.koma.music.service.MediaButtonIntentReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { LogUtils.i(TAG, "Received intent: " + intent); final String intentAction = intent.getAction(); if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(intentAction)) { startService(context, MusicServiceConstants.CMDPAUSE, System.currentTimeMillis()); } else if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) { final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event == null || event.getAction() != KeyEvent.ACTION_UP) { return; }//from www. j av a 2s. c om String command = null; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HEADSETHOOK: command = MusicServiceConstants.CMDHEADSETHOOK; break; case KeyEvent.KEYCODE_MEDIA_STOP: command = MusicServiceConstants.CMDSTOP; break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: command = MusicServiceConstants.CMDTOGGLEPAUSE; break; case KeyEvent.KEYCODE_MEDIA_NEXT: command = MusicServiceConstants.CMDNEXT; break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: command = MusicServiceConstants.CMDPREVIOUS; break; case KeyEvent.KEYCODE_MEDIA_PAUSE: command = MusicServiceConstants.CMDPAUSE; break; case KeyEvent.KEYCODE_MEDIA_PLAY: command = MusicServiceConstants.CMDPLAY; break; } if (command != null) { startService(context, command, event.getEventTime()); if (isOrderedBroadcast()) { abortBroadcast(); } } } }
From source file:etsii_upm.obdii.EnviarService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { // Log.d(TAG, "onStartCommand"); messenger = (Messenger) intent.getParcelableExtra("Messenger"); gestionThread();/*from w w w . j ava2s .c o m*/ return super.onStartCommand(intent, flags, startId); }
From source file:com.scooter1556.sms.android.activity.HomeActivity.java
private void startFullScreenActivityIfNeeded(Intent intent) { if (intent != null && intent.getBooleanExtra(EXTRA_START_FULLSCREEN, false)) { Intent fullScreenIntent = new Intent(this, FullScreenPlayerActivity.class) .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP) .putExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION, intent.getParcelableExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION)); startActivity(fullScreenIntent); }/* w w w .j a v a 2s. c o m*/ }
From source file:com.afwsamples.testdpc.provision.PostProvisioningTask.java
public Intent getPostProvisioningLaunchIntent(Intent intent) { // Enable the profile after provisioning is complete. Intent launch;/*from w w w . ja v a2 s . c om*/ // Retreive the admin extras bundle, which we can use to determine the original context for // TestDPCs launch. PersistableBundle extras = intent.getParcelableExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE); String packageName = mContext.getPackageName(); boolean synchronousAuthLaunch = LaunchIntentUtil.isSynchronousAuthLaunch(extras); boolean cosuLaunch = LaunchIntentUtil.isCosuLaunch(extras); boolean isProfileOwner = mDevicePolicyManager.isProfileOwnerApp(packageName); boolean isDeviceOwner = mDevicePolicyManager.isDeviceOwnerApp(packageName); // Drop out quickly if we're neither profile or device owner. if (!isProfileOwner && !isDeviceOwner) { return null; } if (isProfileOwner) { launch = new Intent(mContext, EnableProfileActivity.class); } else if (cosuLaunch) { launch = new Intent(mContext, EnableCosuActivity.class); launch.putExtra(EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE, extras); } else { launch = new Intent(mContext, EnableDeviceOwnerActivity.class); } if (synchronousAuthLaunch) { String accountName = LaunchIntentUtil.getAddedAccountName(extras); if (accountName != null) { launch.putExtra(LaunchIntentUtil.EXTRA_ACCOUNT_NAME, accountName); } } // For synchronous auth cases, we can assume accounts are already setup (or will be shortly, // as account migration for Profile Owner is asynchronous). For COSU we don't want to show // the account option to the user, as no accounts should be added for now. // In other cases, offer to add an account to the newly configured device/profile. if (!synchronousAuthLaunch && !cosuLaunch) { AccountManager accountManager = AccountManager.get(mContext); Account[] accounts = accountManager.getAccounts(); if (accounts != null && accounts.length == 0) { // Add account after provisioning is complete. Intent addAccountIntent = new Intent(mContext, AddAccountActivity.class); addAccountIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); addAccountIntent.putExtra(AddAccountActivity.EXTRA_NEXT_ACTIVITY_INTENT, launch); return addAccountIntent; } } launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return launch; }
From source file:com.avalond.ad_blocak.vpn.AdVpnService.java
@Override public int onStartCommand(@Nullable Intent intent, int flags, int startId) { Log.i(TAG, "onStartCommand"); switch (intent == null ? Command.START : Command.values()[intent.getIntExtra("COMMAND", Command.START.ordinal())]) { case START:/* w w w . j a va2s . co m*/ startVpn(intent == null ? null : (PendingIntent) intent.getParcelableExtra("NOTIFICATION_INTENT")); break; case STOP: stopVpn(); break; } return Service.START_STICKY; }
From source file:com.cuddlesoft.nori.ImageViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get shared preferences. sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Get data out of Intent sent by SearchActivity or restore them from the saved instance // state.//from ww w. j a va 2s. com int imageIndex; if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_ID_IMAGE_INDEX) && savedInstanceState.containsKey(BUNDLE_ID_SEARCH_RESULT)) { imageIndex = savedInstanceState.getInt(BUNDLE_ID_IMAGE_INDEX); searchResult = savedInstanceState.getParcelable(BUNDLE_ID_SEARCH_RESULT); searchClient = ((SearchClient.Settings) savedInstanceState .getParcelable(BUNDLE_ID_SEARCH_CLIENT_SETTINGS)).createSearchClient(); } else { final Intent intent = getIntent(); imageIndex = intent.getIntExtra(SearchActivity.BUNDLE_ID_IMAGE_INDEX, 0); searchResult = intent.getParcelableExtra(SearchActivity.BUNDLE_ID_SEARCH_RESULT); searchClient = ((SearchClient.Settings) intent .getParcelableExtra(SearchActivity.BUNDLE_ID_SEARCH_CLIENT_SETTINGS)).createSearchClient(); } // Request window features. supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); // Keep screen on, if enabled by the user. if (sharedPreferences.getBoolean(getString(R.string.preference_image_viewer_keepScreenOn_key), true)) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } // Populate content view. setContentView(R.layout.activity_image_viewer); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.hide(); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); // Create and set the image viewer Fragment pager adapter. imagePagerAdapter = new ImagePagerAdapter(getSupportFragmentManager()); viewPager = (ImageViewerPager) findViewById(R.id.image_pager); viewPager.setAdapter(imagePagerAdapter); viewPager.setOnPageChangeListener(this); viewPager.setCurrentItem(imageIndex); // Set up the GestureDetector used to toggle the action bar. gestureDetector = new GestureDetector(this, gestureListener); viewPager.setOnMotionEventListener(this); // Set activity title. setTitle(searchResult.getImages()[imageIndex]); // Dim system UI. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { viewPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } }
From source file:com.example.android.animationsdemo.PayPalActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { DKLog.d(TAG, Trace.getCurrentMethod() + String.format("requestCode: %s, resultCode: %s", requestCode, resultCode)); if (requestCode == SwapubPayPal.REQUEST_CODE_PAYMENT) { if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { try { // Log.i(TAG, confirm.toJSONObject().toString(4)); // Log.i(TAG, confirm.getPayment().toJSONObject().toString(4)); PayPalResponse mPayPalResponse = new PayPalResponse(); mPayPalResponse.parseConfirmData(confirm.toJSONObject()); mPayPalResponse.parsePaymentData(confirm.getPayment().toJSONObject()); /**/*from ww w .ja v a 2s .c om*/ * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification * or consent completion. * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ * for more details. * * For sample mobile backend interactions, see * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend */ Toast.makeText(getApplicationContext(), mPayPalResponse.toString(), Toast.LENGTH_LONG) .show(); } catch (JSONException e) { Log.e(TAG, "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i(TAG, "The user canceled."); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.example.places.fragments.PlaceSearchFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_GET_CURRENT_PLACE) { if (resultCode == Activity.RESULT_OK) { Place place = (Place) data.getParcelableExtra(CurrentPlaceDialogFragment.EXTRA_CURRENT_PLACE); onCurrentPlaceSelected(place); }//from w w w .j a v a 2 s.co m } }
From source file:com.orangelabs.rcs.ri.messaging.chat.ChatView.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != RESULT_OK) { return;/*from ww w . j av a2s. c o m*/ } switch (requestCode) { case SELECT_GEOLOCATION: Geoloc geoloc = data.getParcelableExtra(EditGeoloc.EXTRA_GEOLOC); sendGeoloc(geoloc); break; } }
From source file:com.samebits.beacon.locator.ui.fragment.TrackedBeaconsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == Constants.REQ_UPDATED_ACTION_BEACON) { if (data != null && data.hasExtra(Constants.ARG_ACTION_BEACON)) { ActionBeacon actionBeacon = data.getParcelableExtra(Constants.ARG_ACTION_BEACON); if (actionBeacon != null) { //TODO check if isDirty, now we store always even no changes if (mDataManager.updateBeaconAction(actionBeacon)) { mBeaconsAdapter.updateBeaconAction(actionBeacon); } else { //TODO error }/*from ww w .ja v a 2s . c o m*/ } } } super.onActivityResult(requestCode, resultCode, data); }