Java Code Examples for android.content.Intent#getParcelableArrayListExtra()
The following examples show how to use
android.content.Intent#getParcelableArrayListExtra() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrowserActionsIntentTest.java From custom-tabs-client with Apache License 2.0 | 5 votes |
@Test /** * Test whether custom items are set correctly. */ public void testCustomItem() { PendingIntent action1 = createCustomItemAction(TEST_URL); BrowserActionItem customItemWithoutIcon = new BrowserActionItem(CUSTOM_ITEM_TITLE, action1); PendingIntent action2 = createCustomItemAction(TEST_URL); BrowserActionItem customItemWithIcon = new BrowserActionItem(CUSTOM_ITEM_TITLE, action2, android.R.drawable.ic_menu_share); ArrayList<BrowserActionItem> customItems = new ArrayList<>(); customItems.add(customItemWithIcon); customItems.add(customItemWithoutIcon); BrowserActionsIntent browserActionsIntent = new BrowserActionsIntent.Builder(mContext, mUri) .setCustomItems(customItems) .build(); Intent intent = browserActionsIntent.getIntent(); assertTrue(intent.hasExtra(BrowserActionsIntent.EXTRA_MENU_ITEMS)); ArrayList<Bundle> bundles = intent.getParcelableArrayListExtra(BrowserActionsIntent.EXTRA_MENU_ITEMS); assertNotNull(bundles); List<BrowserActionItem> items = BrowserActionsIntent.parseBrowserActionItems(bundles); assertEquals(2, items.size()); BrowserActionItem items1 = items.get(0); assertEquals(CUSTOM_ITEM_TITLE, items1.getTitle()); assertEquals(android.R.drawable.ic_menu_share, items1.getIconId()); assertEquals(action1, items1.getAction()); BrowserActionItem items2 = items.get(1); assertEquals(CUSTOM_ITEM_TITLE, items2.getTitle()); assertEquals(0, items2.getIconId()); assertEquals(action2, items2.getAction()); }
Example 2
Source File: RelayUtil.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public static @NonNull ArrayList<Uri> getSharedUris(Activity activity) { if (activity != null) { Intent i = activity.getIntent(); if (i != null) { ArrayList<Uri> uris = i.getParcelableArrayListExtra(SHARED_URIS); if (uris != null) return uris; } } return new ArrayList<>(); }
Example 3
Source File: WinnerDeclarationActivity.java From 1Rramp-Android with MIT License | 5 votes |
private void collectExtras() { Intent intent = getIntent(); if (intent != null) { mCompetitionHashtags = intent.getParcelableArrayListExtra(EXTRA_COMPETITION_TAGS); mCompetitionId = intent.getStringExtra(EXTRA_COMPETITION_ID); mCompetitionTitle = intent.getStringExtra(EXTRA_COMPETITION_TITLE); mCompetitionImage = intent.getStringExtra(EXTRA_COMPETITION_IMAGE_URL); } }
Example 4
Source File: AppSettingActivity.java From AndroidDownload with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) { return; } if (requestCode == REQUEST_CODE_CHOOSE) { ArrayList<EssFile> fileList = data.getParcelableArrayListExtra(com.ess.filepicker.util.Const.EXTRA_RESULT_SELECTION); localPathText.setText(fileList.get(0).getAbsolutePath()); appSettingPresenter.setSavePath(fileList.get(0).getAbsolutePath()); } }
Example 5
Source File: PictureSelector.java From PictureSelector with Apache License 2.0 | 5 votes |
/** * @param data * @return Selector Multiple LocalMedia */ public static List<LocalMedia> obtainMultipleResult(Intent data) { if (data != null) { List<LocalMedia> result = data.getParcelableArrayListExtra(PictureConfig.EXTRA_RESULT_SELECTION); return result == null ? new ArrayList<>() : result; } return new ArrayList<>(); }
Example 6
Source File: IntentUtils.java From delion with Apache License 2.0 | 5 votes |
/** * Just link {@link Intent#getParcelableArrayListExtra(String)} but doesn't throw exceptions. */ public static <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra( Intent intent, String name) { try { return intent.getParcelableArrayListExtra(name); } catch (Throwable t) { // Catches un-parceling exceptions. Log.e(TAG, "getParcelableArrayListExtra failed on intent " + intent); return null; } }
Example 7
Source File: IdenticonRemovalService.java From Identiconizer with Apache License 2.0 | 5 votes |
@Override protected void onHandleIntent(Intent intent) { startForeground(SERVICE_NOTIFICATION_ID, createNotification()); // If a predefined contacts list is provided, use it directly. // contactsList is set when this service is started from ContactsListActivity. if (intent.hasExtra("contactsList")) { ArrayList<ContactInfo> contactsList = intent.getParcelableArrayListExtra("contactsList"); processPhotos(contactsList); } else { processPhotos(); } LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("CONTACTS_UPDATED")); stopForeground(true); }
Example 8
Source File: DownloadManagementActivity.java From AndroidDownload with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) { return; } if (requestCode == REQUEST_CODE_CHOOSE) { ArrayList<EssFile> fileList = data.getParcelableArrayListExtra(com.ess.filepicker.util.Const.EXTRA_RESULT_SELECTION); String suffix = fileList.get(0).getName().substring(fileList.get(0).getName().lastIndexOf(".") + 1).toUpperCase(); if("TORRENT".equals(suffix)) { Intent intent = new Intent(this, TorrentInfoActivity.class); intent.putExtra("torrentPath", fileList.get(0).getAbsolutePath()); intent.putExtra("isDown", true); startActivity(intent); }else{ Util.alert(DownloadManagementActivity.this,"选择的文件不是种子文件", Const.ERROR_ALERT); } }else if (requestCode == REQUEST_CODE_SCAN) { final String content = data.getStringExtra(Constant.CODED_CONTENT); new LovelyStandardDialog(this, LovelyStandardDialog.ButtonLayout.VERTICAL) .setTopColorRes(R.color.colorMain) .setIcon(R.drawable.ic_success) .setButtonsColorRes(R.color.colorMain) .setTitle("创建任务") .setMessage(content) .setPositiveButton(android.R.string.ok, new View.OnClickListener() { @Override public void onClick(View v) { downloadManagementPresenter.startTask(content); } }) .show(); } }
Example 9
Source File: DownloadService.java From BlueBoard with Apache License 2.0 | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) { return Service.START_NOT_STICKY; } ArrayList<OkDownloadRequest> downLoadList = intent.getParcelableArrayListExtra(AcString.DOWNLOAD_LIST); initDownload(downLoadList); return Service.START_NOT_STICKY; }
Example 10
Source File: SimprintsCalloutProcessing.java From commcare-android with Apache License 2.0 | 5 votes |
public static OrderedHashtable<String, String> getConfidenceMatchesFromCalloutResponse(Intent intent) { List<Identification> idReadings = intent.getParcelableArrayListExtra(Constants.SIMPRINTS_IDENTIFICATIONS); Collections.sort(idReadings); OrderedHashtable<String, String> guidToConfidenceMap = new OrderedHashtable<>(); for (Identification id : idReadings) { guidToConfidenceMap.put(id.getGuid(), getTierText(id.getTier())); } return guidToConfidenceMap; }
Example 11
Source File: PictureSelectorActivity.java From PictureSelector with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch (requestCode) { case PictureConfig.PREVIEW_VIDEO_CODE: if (data != null) { List<LocalMedia> list = data.getParcelableArrayListExtra(PictureConfig.EXTRA_SELECT_LIST); if (list != null && list.size() > 0) { onResult(list); } } break; case UCrop.REQUEST_CROP: singleCropHandleResult(data); break; case UCrop.REQUEST_MULTI_CROP: multiCropHandleResult(data); break; case PictureConfig.REQUEST_CAMERA: dispatchHandleCamera(data); break; default: break; } } else if (resultCode == RESULT_CANCELED) { previewCallback(data); } else if (resultCode == UCrop.RESULT_ERROR) { if (data != null) { Throwable throwable = (Throwable) data.getSerializableExtra(UCrop.EXTRA_ERROR); if (throwable != null) { ToastUtils.s(getContext(), throwable.getMessage()); } } } }
Example 12
Source File: BrowserActionsIntent.java From custom-tabs-client with Apache License 2.0 | 5 votes |
private static void openFallbackBrowserActionsMenu(Context context, Intent intent) { Uri uri = intent.getData(); int type = intent.getIntExtra(EXTRA_TYPE, URL_TYPE_NONE); ArrayList<Bundle> bundles = intent.getParcelableArrayListExtra(EXTRA_MENU_ITEMS); List<BrowserActionItem> items = bundles != null ? parseBrowserActionItems(bundles) : null; openFallbackBrowserActionsMenu(context, uri, type, items); }
Example 13
Source File: MainActivity.java From ns-usbloader-mobile with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction() == null) return; switch (intent.getAction()) { case UsbManager.ACTION_USB_DEVICE_ATTACHED: usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE); if (usbManager == null) break; // ??? if (usbManager.hasPermission(usbDevice)) isUsbDeviceAccessible = true; else { isUsbDeviceAccessible = false; usbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(context, 0, new Intent(NsConstants.REQUEST_NS_ACCESS_INTENT), 0)); } break; case NsConstants.REQUEST_NS_ACCESS_INTENT: isUsbDeviceAccessible = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false); break; case UsbManager.ACTION_USB_DEVICE_DETACHED: usbDevice = null; isUsbDeviceAccessible = false; stopService(new Intent(context, CommunicationsService.class)); break; case NsConstants.SERVICE_TRANSFER_TASK_FINISHED_INTENT: ArrayList<NSPElement> nspElements = intent.getParcelableArrayListExtra(NsConstants.SERVICE_CONTENT_NSP_LIST); if (nspElements == null) break; for (int i=0; i < mDataset.size(); i++){ for (NSPElement receivedNSPe : nspElements) if (receivedNSPe.getFilename().equals(mDataset.get(i).getFilename())) mDataset.get(i).setStatus(receivedNSPe.getStatus()); } mAdapter.notifyDataSetChanged(); blockUI(false); break; } }
Example 14
Source File: ExplorerActivity.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent i) { if (i.getStringArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS) != null) { ArrayList<BaseFile> failedOps = i.getParcelableArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS); if (failedOps != null) { mainActivityHelper.showFailedOperationDialog(failedOps, i.getBooleanExtra("move", false), ExplorerActivity.this); } } }
Example 15
Source File: AbsBoxingActivity.java From boxing with Apache License 2.0 | 4 votes |
private ArrayList<BaseMedia> getSelectedMedias(Intent intent) { return intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA); }
Example 16
Source File: ProfileActivity.java From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 | 4 votes |
@Override protected void onCreate(final @Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); ArrayList<NavigationActivity.NavigationFragment> fragments = intent.getParcelableArrayListExtra(FRAGMENTS_INTENT); for (NavigationActivity.NavigationFragment navigationFragment : fragments) { mItems.put(getString(navigationFragment.mId), getFragment(navigationFragment.mId, navigationFragment.mFragmentClass)); } mItems.remove("Spectrum"); if (mItems.size() < 1) { Utils.toast(R.string.sections_disabled, this); finish(); return; } mProfilePosition = intent.getIntExtra(POSITION_INTENT, -1); if (savedInstanceState != null && (mMode = savedInstanceState.getInt("mode")) != 0) { if (mMode == 1) { initNewMode(savedInstanceState); } else { currentSettings(); } } else { new Dialog(this).setItems(getResources().getStringArray(R.array.profile_modes), (dialog, which) -> { switch (which) { case 0: initNewMode(savedInstanceState); break; case 1: currentSettings(); break; } }).setCancelable(false).show(); } }
Example 17
Source File: MainActivity.java From Augendiagnose with GNU General Public License v2.0 | 4 votes |
@Override protected final void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (isCreationFailed()) { return; } if (VERSION.SDK_INT >= VERSION_CODES.N && isInMultiWindowMode() && !SystemUtil.isTablet()) { setContentView(R.layout.activity_main_splitscreen); } else { setContentView(R.layout.activity_main); } PreferenceUtil.setSharedPreferenceBoolean(R.string.key_internal_organized_new_photo, false); Intent intent = getIntent(); if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction()) && intent.getType() != null) { // Application was started from other application by passing a list of images - open // OrganizeNewPhotosActivity. ArrayList<Uri> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (imageUris != null) { ArrayList<String> fileNames = new ArrayList<>(); for (int i = 0; i < imageUris.size(); i++) { if (ImageUtil.getMimeType(imageUris.get(i)).startsWith("image/")) { String fileName = MediaStoreUtil.getRealPathFromUri(imageUris.get(i)); if (fileName == null) { fileName = imageUris.get(i).getPath(); } fileNames.add(fileName); } } boolean rightEyeLast = PreferenceUtil.getSharedPreferenceBoolean(R.string.key_eye_sequence_choice); OrganizeNewPhotosActivity.startActivity(this, fileNames.toArray(new String[fileNames.size()]), rightEyeLast, NextAction.NEXT_IMAGES); } } if (!SystemUtil.isAppInstalled(getString(R.string.package_eyefi)) && !SystemUtil.isAppInstalled(getString(R.string.package_mobi))) { Button buttonEyeFi = findViewById(R.id.mainButtonOpenEyeFiApp); buttonEyeFi.setVisibility(View.GONE); } if (!SystemUtil.hasCamera()) { Button buttonTakePhotos = findViewById(R.id.mainButtonTakePictures); buttonTakePhotos.setVisibility(View.GONE); } if (savedInstanceState == null) { PreferenceUtil.incrementCounter(R.string.key_statistics_countmain); } }
Example 18
Source File: UCropActivity.java From EasyPhotos with Apache License 2.0 | 4 votes |
/** * This method extracts {@link com.yalantis.ucrop.UCrop.Options #optionsBundle} from incoming intent * and setups Activity, {@link OverlayView} and {@link CropImageView} properly. */ @SuppressWarnings("deprecation") private void processOptions(@NonNull Intent intent) { // Bitmap compression options String compressionFormatName = intent.getStringExtra(UCrop.Options.EXTRA_COMPRESSION_FORMAT_NAME); Bitmap.CompressFormat compressFormat = null; if (!TextUtils.isEmpty(compressionFormatName)) { compressFormat = Bitmap.CompressFormat.valueOf(compressionFormatName); } mCompressFormat = (compressFormat == null) ? DEFAULT_COMPRESS_FORMAT : compressFormat; mCompressQuality = intent.getIntExtra(UCrop.Options.EXTRA_COMPRESSION_QUALITY, UCropActivity.DEFAULT_COMPRESS_QUALITY); // Gestures options int[] allowedGestures = intent.getIntArrayExtra(UCrop.Options.EXTRA_ALLOWED_GESTURES); if (allowedGestures != null && allowedGestures.length == TABS_COUNT) { mAllowedGestures = allowedGestures; } // Crop image view options mGestureCropImageView.setMaxBitmapSize(intent.getIntExtra(UCrop.Options.EXTRA_MAX_BITMAP_SIZE, CropImageView.DEFAULT_MAX_BITMAP_SIZE)); mGestureCropImageView.setMaxScaleMultiplier(intent.getFloatExtra(UCrop.Options.EXTRA_MAX_SCALE_MULTIPLIER, CropImageView.DEFAULT_MAX_SCALE_MULTIPLIER)); mGestureCropImageView.setImageToWrapCropBoundsAnimDuration(intent.getIntExtra(UCrop.Options.EXTRA_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION, CropImageView.DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION)); // Overlay view options mOverlayView.setFreestyleCropEnabled(intent.getBooleanExtra(UCrop.Options.EXTRA_FREE_STYLE_CROP, OverlayView.DEFAULT_FREESTYLE_CROP_MODE != OverlayView.FREESTYLE_CROP_MODE_DISABLE)); mOverlayView.setDimmedColor(intent.getIntExtra(UCrop.Options.EXTRA_DIMMED_LAYER_COLOR, getResources().getColor(R.color.ucrop_color_default_dimmed))); mOverlayView.setCircleDimmedLayer(intent.getBooleanExtra(UCrop.Options.EXTRA_CIRCLE_DIMMED_LAYER, OverlayView.DEFAULT_CIRCLE_DIMMED_LAYER)); mOverlayView.setShowCropFrame(intent.getBooleanExtra(UCrop.Options.EXTRA_SHOW_CROP_FRAME, OverlayView.DEFAULT_SHOW_CROP_FRAME)); mOverlayView.setCropFrameColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_FRAME_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_frame))); mOverlayView.setCropFrameStrokeWidth(intent.getIntExtra(UCrop.Options.EXTRA_CROP_FRAME_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_frame_stoke_width))); mOverlayView.setShowCropGrid(intent.getBooleanExtra(UCrop.Options.EXTRA_SHOW_CROP_GRID, OverlayView.DEFAULT_SHOW_CROP_GRID)); mOverlayView.setCropGridRowCount(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_ROW_COUNT, OverlayView.DEFAULT_CROP_GRID_ROW_COUNT)); mOverlayView.setCropGridColumnCount(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_COLUMN_COUNT, OverlayView.DEFAULT_CROP_GRID_COLUMN_COUNT)); mOverlayView.setCropGridColor(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_COLOR, getResources().getColor(R.color.ucrop_color_default_crop_grid))); mOverlayView.setCropGridStrokeWidth(intent.getIntExtra(UCrop.Options.EXTRA_CROP_GRID_STROKE_WIDTH, getResources().getDimensionPixelSize(R.dimen.ucrop_default_crop_grid_stoke_width))); // Aspect ratio options float aspectRatioX = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_X, 0); float aspectRatioY = intent.getFloatExtra(UCrop.EXTRA_ASPECT_RATIO_Y, 0); int aspectRationSelectedByDefault = intent.getIntExtra(UCrop.Options.EXTRA_ASPECT_RATIO_SELECTED_BY_DEFAULT, 0); ArrayList<AspectRatio> aspectRatioList = intent.getParcelableArrayListExtra(UCrop.Options.EXTRA_ASPECT_RATIO_OPTIONS); if (aspectRatioX > 0 && aspectRatioY > 0) { if (mWrapperStateAspectRatio != null) { mWrapperStateAspectRatio.setVisibility(View.GONE); } mGestureCropImageView.setTargetAspectRatio(aspectRatioX / aspectRatioY); } else if (aspectRatioList != null && aspectRationSelectedByDefault < aspectRatioList.size()) { mGestureCropImageView.setTargetAspectRatio(aspectRatioList.get(aspectRationSelectedByDefault).getAspectRatioX() / aspectRatioList.get(aspectRationSelectedByDefault).getAspectRatioY()); } else { mGestureCropImageView.setTargetAspectRatio(CropImageView.SOURCE_IMAGE_ASPECT_RATIO); } // Result bitmap max size options int maxSizeX = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_X, 0); int maxSizeY = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_Y, 0); if (maxSizeX > 0 && maxSizeY > 0) { mGestureCropImageView.setMaxResultImageSizeX(maxSizeX); mGestureCropImageView.setMaxResultImageSizeY(maxSizeY); } }
Example 19
Source File: PlaybackAndroidService.java From PainlessMusicPlayer with Apache License 2.0 | 4 votes |
private void onActionPlay(@NonNull final Intent intent) { final List<Media> queue = intent.getParcelableArrayListExtra(EXTRA_QUEUE); final int position = intent.getIntExtra(EXTRA_POSITION, 0); service.play(queue, position); }
Example 20
Source File: Matisse.java From Matisse with Apache License 2.0 | 2 votes |
/** * Obtain user selected media' {@link Uri} list in the starting Activity or Fragment. * * @param data Intent passed by {@link Activity#onActivityResult(int, int, Intent)} or * {@link Fragment#onActivityResult(int, int, Intent)}. * @return User selected media' {@link Uri} list. */ public static List<Uri> obtainResult(Intent data) { return data.getParcelableArrayListExtra(MatisseActivity.EXTRA_RESULT_SELECTION); }