List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.microsoft.rightsmanagement.ui.UserPolicyViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Logger.ms(TAG, "onCreate"); super.onCreate(savedInstanceState); int layoutId = R.layout.user_policy_viewer_activity_layout; setContentView(layoutId);//from w w w. ja v a 2s.c om Intent intent = getIntent(); mRequestCallbackId = intent.getIntExtra(REQUEST_CALLBACK_ID, 0); mUserPolicyViewerActivityRequestOption = intent.getIntExtra(REQUEST_RESULT_POLICY_VIEWER_OPTIONS, UserPolicyViewerActivityRequestOption.NONE); Parcelable possbileUserPolicyModelInstance = intent.getParcelableExtra(REQUEST_RESULT_USER_POLICY_MODEL); try { mUserPolicyModel = (UserPolicyModel) possbileUserPolicyModelInstance; } catch (ClassCastException ex) { Logger.ie(TAG, ex.getMessage()); } addUserPolicyViewerFragment(); addTransparentPartDismissListener(R.id.user_policy_viewer_transparent_part); // create fader animators createBgAnimators(R.id.user_policy_viewer_base_container, savedInstanceState); Logger.me(TAG, "onCreate"); }
From source file:com.rosterloh.moodring.profile.BleProfileService.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent == null || !intent.hasExtra(EXTRA_DEVICE_ADDRESS)) throw new UnsupportedOperationException("No device address at EXTRA_DEVICE_ADDRESS key"); final Uri logUri = intent.getParcelableExtra(EXTRA_LOG_URI); mDeviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS); Log.i(TAG, "Service started"); // notify user about changing the state to CONNECTING final Intent broadcast = new Intent(BROADCAST_CONNECTION_STATE); broadcast.putExtra(EXTRA_CONNECTION_STATE, STATE_CONNECTING); LocalBroadcastManager.getInstance(BleProfileService.this).sendBroadcast(broadcast); final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE); final BluetoothAdapter adapter = bluetoothManager.getAdapter(); final BluetoothDevice device = adapter.getRemoteDevice(mDeviceAddress); mDeviceName = device.getName();/* w ww .j av a2s . com*/ onServiceStarted(); Log.v(TAG, "Connecting..."); mBleManager.connect(BleProfileService.this, device); return START_REDELIVER_INTENT; }
From source file:com.hippo.nimingban.ui.PostActivity.java
private Bundle createArgs() { Bundle bundle = new Bundle(); Intent intent = getIntent(); if (intent != null) { bundle.putString(PostFragment.KEY_ACTION, intent.getAction()); bundle.putParcelable(PostFragment.KEY_DATA, intent.getData()); bundle.putInt(PostFragment.KEY_SITE, intent.getIntExtra(KEY_SITE, -1)); bundle.putString(PostFragment.KEY_ID, intent.getStringExtra(KEY_ID)); bundle.putParcelable(PostFragment.KEY_POST, intent.getParcelableExtra(KEY_POST)); }// ww w. j a v a 2 s . c o m return bundle; }
From source file:com.abhijitvalluri.android.fitnotifications.AppChoicesActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case APP_SELECTIONS_REQUEST: if (resultCode == RESULT_OK) { AppSelection appSelection = data.getParcelableExtra(AppSettingsActivity.APP_SELECTION_EXTRA); if (appSelection != null) { mAppSelectionsStore.updateAppSelection(appSelection); updateAppSelections(appSelection); }//w w w. j av a2 s . co m } break; default: } }
From source file:com.actinarium.nagbox.service.NagboxService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;/*from w ww . j a v a 2 s.c o m*/ } // I know that only either of those is needed, but for the sake of nice code I'm pulling these here final Task task = intent.getParcelableExtra(EXTRA_TASK); final long id = intent.getLongExtra(EXTRA_TASK_ID, Task.NO_ID); switch (intent.getAction()) { case ACTION_UPDATE_TASK_STATUS: handleUpdateTaskStatus(task); break; case ACTION_ON_ALARM_FIRED: handleOnAlarmFired(); break; case ACTION_ON_NOTIFICATION_DISMISSED: handleOnNotificationDismissed(id); break; case ACTION_ON_NOTIFICATION_ACTION_STOP_TASK: int notificationIdToCancel = intent.getIntExtra(EXTRA_CANCEL_NOTIFICATION_ID, -1); handleStopTaskById(id, notificationIdToCancel); break; case ACTION_CREATE_TASK: handleCreateTask(task); break; case ACTION_UPDATE_TASK: handleUpdateTask(task); break; case ACTION_DELETE_TASK: handleDeleteTask(id); break; case ACTION_RESTORE_TASK: handleRestoreTask(task); break; } // Release the wake lock, if there was any. WakefulBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.av.remusic.receiver.MediaButtonIntentReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { final String intentAction = intent.getAction(); if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(intentAction)) { if (true) startService(context, MediaService.CMDPAUSE); } else if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) { final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event == null) { return; }//from ww w . jav a2 s. c o m final int keycode = event.getKeyCode(); final int action = event.getAction(); final long eventtime = event.getEventTime(); String command = null; switch (keycode) { case KeyEvent.KEYCODE_MEDIA_STOP: command = MediaService.CMDSTOP; break; case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: command = MediaService.CMDTOGGLEPAUSE; break; case KeyEvent.KEYCODE_MEDIA_NEXT: command = MediaService.CMDNEXT; break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: command = MediaService.CMDPREVIOUS; break; case KeyEvent.KEYCODE_MEDIA_PAUSE: command = MediaService.CMDPAUSE; break; case KeyEvent.KEYCODE_MEDIA_PLAY: command = MediaService.CMDPLAY; break; } if (command != null) { if (action == KeyEvent.ACTION_DOWN) { if (mDown) { if (MediaService.CMDTOGGLEPAUSE.equals(command) || MediaService.CMDPLAY.equals(command)) { if (mLastClickTime != 0 && eventtime - mLastClickTime > LONG_PRESS_DELAY) { acquireWakeLockAndSendMessage(context, mHandler.obtainMessage(MSG_LONGPRESS_TIMEOUT, context), 0); } } } else if (event.getRepeatCount() == 0) { if (keycode == KeyEvent.KEYCODE_HEADSETHOOK) { if (eventtime - mLastClickTime >= DOUBLE_CLICK) { mClickCounter = 0; } mClickCounter++; if (DEBUG) Log.v(TAG, "Got headset click, count = " + mClickCounter); mHandler.removeMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT); Message msg = mHandler.obtainMessage(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, mClickCounter, 0, context); long delay = mClickCounter < 3 ? DOUBLE_CLICK : 0; if (mClickCounter >= 3) { mClickCounter = 0; } mLastClickTime = eventtime; acquireWakeLockAndSendMessage(context, msg, delay); } else { startService(context, command); } mLaunched = false; mDown = true; } } else { mHandler.removeMessages(MSG_LONGPRESS_TIMEOUT); mDown = false; } if (isOrderedBroadcast()) { abortBroadcast(); } releaseWakeLockIfHandlerIdle(); } } }
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
/** * Derive {@link Tracks#CONTENT_ITEM_TYPE} {@link Uri} based on incoming * {@link Intent}, using {@link #EXTRA_TRACK} when set. *///from www . ja va 2 s. c o m private Uri resolveTrackUri(Intent intent) { final Uri trackUri = intent.getParcelableExtra(EXTRA_TRACK); if (trackUri != null) { return trackUri; } else { return Sessions.buildTracksDirUri(mSessionId); } }
From source file:cn.jarlen.media.sample.VideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent(); String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown scheme\n"); finish();//from w ww. j a v a 2 s . c o m return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); mMediaController = new AndroidMediaController(this, false); mMediaController.setSupportActionBar(actionBar); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.photoselection_activity); if (savedInstanceState != null) { mCurrentPhotoUri = savedInstanceState.getParcelable(KEY_CURRENT_PHOTO_URI); mSubActivityInProgress = savedInstanceState.getBoolean(KEY_SUB_ACTIVITY_IN_PROGRESS); }// ww w. j a v a2s . com // Pull data out of the intent. final Intent intent = getIntent(); mPhotoUri = intent.getParcelableExtra(PHOTO_URI); mState = (RawContactDeltaList) intent.getParcelableExtra(ENTITY_DELTA_LIST); mIsProfile = intent.getBooleanExtra(IS_PROFILE, false); mIsDirectoryContact = intent.getBooleanExtra(IS_DIRECTORY_CONTACT, false); mExpandPhoto = intent.getBooleanExtra(EXPAND_PHOTO, false); // Pull out photo expansion properties from resources mExpandedPhotoSize = getResources().getDimensionPixelSize(R.dimen.detail_contact_photo_expanded_size); mHeightOffset = getResources().getDimensionPixelOffset(R.dimen.expanded_photo_height_offset); mBackdrop = findViewById(R.id.backdrop); mPhotoView = (ImageView) findViewById(R.id.photo); mSourceBounds = intent.getSourceBounds(); // Fade in the background. animateInBackground(); // Dismiss the dialog on clicking the backdrop. mBackdrop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); // Wait until the layout pass to show the photo, so that the source bounds will match up. SchedulingUtils.doAfterLayout(mBackdrop, new Runnable() { @Override public void run() { displayPhoto(); } }); }
From source file:com.example.yf.ijkplayerdemo.activities.VideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent(); String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown ccheme\n"); finish();//from www . j ava 2s.com return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); mMediaController = new AndroidMediaController(this, false); mMediaController.setSupportActionBar(actionBar); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }