本文整理汇总了Java中android.content.Intent.getParcelableExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getParcelableExtra方法的具体用法?Java Intent.getParcelableExtra怎么用?Java Intent.getParcelableExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getParcelableExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case Installer.ACTION_INSTALL_STARTED:
break;
case Installer.ACTION_INSTALL_COMPLETE:
localBroadcastManager.unregisterReceiver(this);
showRelevantView(true);
break;
case Installer.ACTION_INSTALL_INTERRUPTED:
localBroadcastManager.unregisterReceiver(this);
// TODO: handle errors!
break;
case Installer.ACTION_INSTALL_USER_INTERACTION:
PendingIntent installPendingIntent =
intent.getParcelableExtra(Installer.EXTRA_USER_INTERACTION_PI);
try {
installPendingIntent.send();
} catch (PendingIntent.CanceledException e) {
Log.e(TAG, "PI canceled", e);
}
break;
default:
throw new RuntimeException("intent action not handled!");
}
}
示例2: setPowerNotificationRingtone
import android.content.Intent; //导入方法依赖的package包/类
private void setPowerNotificationRingtone(Intent intent) {
final Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
final String toneName;
final String toneUriPath;
if ( uri != null ) {
final Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), uri);
toneName = ringtone.getTitle(getActivity());
toneUriPath = uri.toString();
} else {
// silent
toneName = getString(R.string.power_notifications_ringtone_silent);
toneUriPath = POWER_NOTIFICATIONS_SILENT_URI;
}
mPowerSoundsRingtone.setSummary(toneName);
CMSettings.Global.putString(getContentResolver(),
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE, toneUriPath);
}
示例3: iniitialize
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void iniitialize(Intent intent, Bundle bundle) {
if (!_DEVELOP_MODE) {
if (bundle != null) {
usuario = bundle.getParcelable(EXTRA_USER);
} else {
FIRST_TIME = intent.getBooleanExtra(Constants._FIRST_TIME, false);
usuario = intent.getParcelableExtra(EXTRA_USER);
}
if (FIRST_TIME) {
view.disableEditEmail();
}
view.setupViews(usuario);
}
}
示例4: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) {
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
Log.d(TAG, "USB DVB-T attached: " + usbDevice.getDeviceName());
Intent newIntent = new Intent(ACTION_DVB_DEVICE_ATTACHED);
newIntent.putExtra(UsbManager.EXTRA_DEVICE, usbDevice);
try {
startActivity(newIntent);
} catch (ActivityNotFoundException e) {
Log.d(TAG, "No activity found for DVB-T handling");
}
}
finish();
}
示例5: onNewIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) {
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
RobotLog.vv(TAG, "ACTION_USB_DEVICE_ATTACHED: %s", usbDevice.getDeviceName());
if (usbDevice != null) { // paranoia
// We might get attachment notifications before the event loop is set up, so
// we hold on to them and pass them along only when we're good and ready.
if (receivedUsbAttachmentNotifications != null) { // *total* paranoia
receivedUsbAttachmentNotifications.add(usbDevice);
passReceivedUsbAttachmentsToEventLoop();
}
}
}
}
示例6: handleSendImage
import android.content.Intent; //导入方法依赖的package包/类
@Nullable
private String handleSendImage(Intent intent) {
Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) {
try {
final InputStream imageStream = getCurrentActivity().getContentResolver().openInputStream(imageUri);
final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
String encodedImage = encodeImage(selectedImage);
return encodedImage;
} catch(IOException e) {
}
}
return null;
}
示例7: onNewIntent
import android.content.Intent; //导入方法依赖的package包/类
public void onNewIntent(Intent intent) {
Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
NdefMessage ndefMessage = new NdefMessage(new NdefRecord[]{createUriRecord(mUri)});
boolean result = writeTag(ndefMessage, detectedTag);
if (result) {
Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
}
}
示例8: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
@SuppressLint("NewApi")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.crop_image_activity);
mCropImageView = (CropImageView) findViewById(R.id.cropImageView);
Intent intent = getIntent();
mCropImageUri = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_SOURCE);
mOptions = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
if (savedInstanceState == null) {
if (mCropImageUri == null || mCropImageUri.equals(Uri.EMPTY)) {
if (CropImage.isExplicitCameraPermissionRequired(this)) {
// request permissions and handle the result in onRequestPermissionsResult()
requestPermissions(new String[]{Manifest.permission.CAMERA}, CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE);
} else {
CropImage.startPickImageActivity(this);
}
} else if (CropImage.isReadExternalStoragePermissionsRequired(this, mCropImageUri)) {
// request permissions and handle the result in onRequestPermissionsResult()
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
} else {
// no permissions required or already grunted, can start crop image activity
mCropImageView.setImageUriAsync(mCropImageUri);
}
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
String title = mOptions.activityTitle != null && !mOptions.activityTitle.isEmpty()
? mOptions.activityTitle
: getResources().getString(R.string.crop_image_activity_title);
actionBar.setTitle(title);
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
示例9: checkLocalStreams
import android.content.Intent; //导入方法依赖的package包/类
public static ArrayList<Uri> checkLocalStreams(Activity activity) {
Intent intent = activity.getIntent();
if (intent == null) {
return null;
}
Bundle extras = intent.getExtras();
String action = intent.getAction();
if (extras == null || action == null) {
return null;
}
if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
if (extras.containsKey(Intent.EXTRA_STREAM)) {
return intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
}
}
if (Intent.ACTION_SEND.equals(action)) {
if (extras.containsKey(Intent.EXTRA_STREAM)) {
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (uri != null) {
ArrayList<Uri> streams = new ArrayList<>(1);
streams.add(uri);
return streams;
}
}
}
return null;
}
示例10: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Intent vpnIntent = intent.getParcelableExtra(EXTRA_VPN_INTENT);
config = intent.getParcelableExtra(EXTRA_VPN_CONFIGURATION);
startActivityForResult(vpnIntent, VPN_REQUEST_CODE);
}
示例11: performReceive
import android.content.Intent; //导入方法依赖的package包/类
public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered,
boolean sticky, int sendingUser) throws RemoteException {
if (!accept(intent)) {
return;
}
if (intent.hasExtra("_VA_|_intent_")) {
intent = intent.getParcelableExtra("_VA_|_intent_");
}
SpecialComponentList.unprotectIntent(intent);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
IIntentReceiverJB.performReceive.call(mOld, intent, resultCode, data, extras, ordered, sticky, sendingUser);
} else {
mirror.android.content.IIntentReceiver.performReceive.call(mOld, intent, resultCode, data, extras, ordered, sticky);
}
}
示例12: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == NEW_TRIP_REQUEST) {
if (data != null && data.hasExtra("TRIP")) {
Parcelable par = data.getParcelableExtra("TRIP");
Trip t = Parcels.unwrap(par);
topRef.push().setValue(t);
Snackbar.make(toolbar, "New Trip Added", Snackbar.LENGTH_SHORT).show();
}
}
else
super.onActivityResult(requestCode, resultCode, data);
}
示例13: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
String deviceName = usbDevice.getDeviceName();
if (UsbStorageProvider.ACTION_USB_PERMISSION.equals(action)) {
boolean permission = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false);
if (permission) {
discoverDevice(usbDevice);
notifyRootsChanged();
notifyDocumentsChanged(getContext(), getRootId(usbDevice)+ROOT_SEPERATOR);
} else {
// so we don't ask for permission again
}
} else if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)
|| UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
updateRoots();
}
}
示例14: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final DriveId driveId = intent.getParcelableExtra(GDriveEventService.BUNDLE_DRIVEID);
Log.i(TAG, "onReceive completion event for driveID:" + driveId.encodeToString());
if (driveId.equals(mDriveId)) {
result = intent.getIntExtra(GDriveEventService.BUNDLE_SUCCESS, -1);
synchronized (this) {
notify();
}
}
}
示例15: onStart
import android.content.Intent; //导入方法依赖的package包/类
public int onStart(Context context, Intent intent, int flags, int startId) throws Exception {
Intent targetIntent = intent.getParcelableExtra(Env.EXTRA_TARGET_INTENT);
if (targetIntent != null) {
ServiceInfo targetInfo = PluginManager.getInstance().resolveServiceInfo(targetIntent, 0);
if (targetInfo != null) {
Service service = mNameService.get(targetInfo.name);
if (service == null) {
handleCreateServiceOne(context, intent, targetInfo);
}
handleOnStartOne(targetIntent, flags, startId);
}
}
return -1;
}