List of usage examples for android.content Intent getParcelableArrayListExtra
public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name)
From source file:com.Jsu.framework.image.imageChooser.ImageChooserManager.java
@SuppressLint("NewApi") private void processImageFromGallery(Intent data) { if (data != null && data.getDataString() != null) { String uri = data.getData().toString(); sanitizeURI(uri);//from w ww. jav a2s.c om if (filePathOriginal == null || TextUtils.isEmpty(filePathOriginal)) { onError("File path was null"); } else { if (BuildConfig.DEBUG) { Log.i(TAG, "File: " + filePathOriginal); } String path = filePathOriginal; ImageProcessorThread thread = new ImageProcessorThread(path, foldername, shouldCreateThumbnails); thread.clearOldFiles(clearOldFiles); thread.setListener(this); thread.setContext(getContext()); thread.start(); } } else if (data.getClipData() != null || data.hasExtra("uris")) { // Multiple Images String[] filePaths; if (data.hasExtra("uris")) { ArrayList<Uri> uris = data.getParcelableArrayListExtra("uris"); filePaths = new String[uris.size()]; for (int i = 0; i < uris.size(); i++) { filePaths[i] = uris.get(i).toString(); } } else { ClipData clipData = data.getClipData(); int count = clipData.getItemCount(); filePaths = new String[count]; for (int i = 0; i < count; i++) { ClipData.Item item = clipData.getItemAt(i); Log.i(TAG, "processImageFromGallery: Item: " + item.getUri()); filePaths[i] = item.getUri().toString(); } } ImageProcessorThread thread = new ImageProcessorThread(filePaths, foldername, shouldCreateThumbnails); thread.clearOldFiles(clearOldFiles); thread.setListener(this); thread.setContext(getContext()); thread.start(); // } else if () { } else { onError("Image Uri was null!"); } }
From source file:com.openerp.addons.messages.MessageComposeActivty.java
/** * Handle message intent filter for attachments * // w w w.j a v a 2 s. c o m * @param intent */ private void handleIntentFilter(Intent intent) { attachments_type.put(ATTACHMENT_TYPE.IMAGE, "image/*"); attachments_type.put(ATTACHMENT_TYPE.TEXT_FILE, "application/*"); String action = intent.getAction(); String type = intent.getType(); // Single attachment if (Intent.ACTION_SEND.equals(action) && type != null) { Uri fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); file_uris.add(fileUri); handleReceivedFile(); } // Multiple Attachments if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { ArrayList<Uri> fileUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); file_uris.addAll(fileUris); handleReceivedFile(); } // note.note send as mail if (intent.hasExtra("note_body")) { EditText edtBody = (EditText) findViewById(R.id.edtMessageBody); String body = intent.getExtras().getString("note_body"); edtBody.setText(HTMLHelper.stringToHtml(body)); is_note_body = true; } }
From source file:com.jea.gisandroidapplication.controller.activity.MapActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to if (requestCode == SETTINGS_REQUEST) { // Preferences changed // Check for change if (mLocationPref != sharedPref.getBoolean(SettingsActivity.KEY_PREF_LOCATION, true)) { mLocationPref = sharedPref.getBoolean(SettingsActivity.KEY_PREF_LOCATION, true); // Turn off location for fragment mMapFragment.toggleLocation(); // Hide location FAB toggleLocFabVisibility();/*from w ww . java2 s.co m*/ } } else if (requestCode == FIND_REQUEST) { if (resultCode == RESULT_OK) { // Close navigation drawer closeDrawer(); // Get results from data intent ArrayList<Result> results = data.getParcelableArrayListExtra(FindActivity.EXTRA_RESULTS); // Display results displayResults(results); } } else if (requestCode == STREET_VIEW_REQUEST) { // Required? } else if (requestCode == GOOGLE_ERROR_DIALOG_REQUEST) { // ? } else if (requestCode == LAYER_MANAGER_REQUEST) { if (resultCode == RESULT_OK) { boolean isAdd = data.getBooleanExtra(LayerManagerActivity.EXTRA_LAYER_ISADD, true); String layerName = data.getStringExtra(LayerManagerActivity.EXTRA_LAYER_NAME); if (isAdd) { mMapFragment.addExtraLayer(layerName); } else { // Remove mMapFragment.removeLayer(layerName); } } } }
From source file:org.thoughtcrime.securesms.ProfileFragment.java
@Override public void onActivityResult(int reqCode, int resultCode, Intent data) { switch (reqCode) { case PICK_CONTACT: if (data == null || resultCode != Activity.RESULT_OK) return; List<ContactAccessor.ContactData> selected = data.getParcelableArrayListExtra("contacts"); for (ContactAccessor.ContactData contact : selected) { for (ContactAccessor.NumberData numberData : contact.numbers) { Recipient recipient = RecipientFactory .getRecipientsFromString(getActivity(), numberData.number, false).getPrimaryRecipient(); if (!selectedContacts.contains(recipient) && (existingContacts == null || !existingContacts.contains(recipient))) { addSelectedContact(recipient); }//w ww. ja v a 2 s. c om } } syncAdapterWithSelectedContacts(); break; } }
From source file:com.krayzk9s.imgurholo.activities.MainActivity.java
private void processIntent(Intent intent) { String action = intent.getAction(); String type = intent.getType(); Log.d("New Intent", intent.toString()); if (Intent.ACTION_SEND.equals(action) && type != null) { if (type.startsWith("image/")) { Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); Intent serviceIntent = new Intent(this, UploadService.class); if (intent.getExtras() == null) finish();// w w w . j av a2 s . c o m serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM")); startService(serviceIntent); finish(); } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { Log.d("sending", "sending multiple"); Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); Intent serviceIntent = new Intent(this, UploadService.class); serviceIntent.putParcelableArrayListExtra("images", list); startService(serviceIntent); finish(); } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("imgur-holo")) { Uri uri = intent.getData(); Log.d("URI", "" + action + "/" + type); String uripath = ""; if (uri != null) uripath = uri.toString(); Log.d("URI", uripath); Log.d("URI", "HERE"); if (uri != null && uripath.startsWith(ApiCall.OAUTH_CALLBACK_URL)) { apiCall.verifier = new Verifier(uri.getQueryParameter("code")); CallbackAsync callbackAsync = new CallbackAsync(apiCall, this); callbackAsync.execute(); } } else if (getSupportFragmentManager().getFragments() == null) { loadDefaultPage(); } }
From source file:com.stfalcon.contentmanager.ContentManager.java
private void handleFileContent(final Intent intent) { List<String> uris = new ArrayList<>(); if (intent.getDataString() != null) { String uri = intent.getDataString(); uris.add(uri);/*from ww w . ja v a 2 s.com*/ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (intent.getClipData() != null) { ClipData clipData = intent.getClipData(); for (int i = 0; i < clipData.getItemCount(); i++) { ClipData.Item item = clipData.getItemAt(i); Log.d("TAG", "Item [" + i + "]: " + item.getUri().toString()); uris.add(item.getUri().toString()); } } } if (intent.hasExtra("uris")) { ArrayList<Uri> paths = intent.getParcelableArrayListExtra("uris"); for (int i = 0; i < paths.size(); i++) { uris.add(paths.get(i).toString()); } } //TODO Handle multiple file choose processFile(uris.get(0)); }
From source file:com.github.jvanhie.discogsscrobbler.util.NowPlayingService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent.getBooleanExtra(NEXT_TRACK_MODE, false)) { /*request to start scrobbling the next track, check if it is sound*/ int pos = intent.getIntExtra(NEXT_TRACK_ID, 0); String title = intent.getStringExtra(NEXT_TRACK_TITLE); if (trackList != null && trackList.size() > 0) { //done listening to the previous track -> scrobble the previous track int now = (int) (System.currentTimeMillis() / 1000); mLastfm.scrobbleTrack(track, now, new Lastfm.LastfmWaiter() { @Override/*from www .ja va 2 s .c om*/ public void onResult(boolean success) { //the user already sees the notification, no need for extras notifications atm. } }); mTrackDone = 0; if (pos == -1 && trackList.get(0).title.equals(title)) { //stop requested stop(); } else if (pos < trackList.size() && trackList.get(pos).title.equals(title)) { //ok, this is a valid request, make it happen play(pos); } } /*release the wakelock if it was called via the now playing alarm*/ NowPlayingAlarm.completeWakefulIntent(intent); } else { /*we have received a playlist, start playing*/ trackList = intent.getParcelableArrayListExtra(TRACK_LIST); thumb = intent.getStringExtra(THUMB_URL); albumArtURL = intent.getStringExtra(ALBUM_ART_URL); releaseId = intent.getLongExtra(RELEASE_ID, 0); currentTrack = 0; /*first try to load the album art, then start playing*/ mImageLoader.loadImage(this, thumb, new ImageLoadingListener() { @Override public void onLoadingStarted() { } @Override public void onLoadingCancelled() { } @Override public void onLoadingFailed(FailReason failReason) { mNotificationBuilder.setLargeIcon(null); play(currentTrack); } @Override public void onLoadingComplete(Bitmap loadedImage) { mNotificationBuilder.setLargeIcon(loadedImage); play(currentTrack); } }); } return (START_NOT_STICKY); }
From source file:com.tonyodev.fetch.FetchService.java
private void processAction(final Intent intent) { if (intent == null) { return;//from w ww.j a v a 2 s. co m } if (!executor.isShutdown()) { executor.execute(new Runnable() { @Override public void run() { final long id = intent.getLongExtra(EXTRA_ID, DEFAULT_EMPTY_VALUE); switch (intent.getIntExtra(ACTION_TYPE, DEFAULT_EMPTY_VALUE)) { case ACTION_PAUSE: { pause(id); break; } case ACTION_REMOVE: { remove(id); break; } case ACTION_RESUME: { resume(id); break; } case ACTION_ENQUEUE: { String url = intent.getStringExtra(EXTRA_URL); String filePath = intent.getStringExtra(EXTRA_FILE_PATH); ArrayList<Bundle> headers = intent.getParcelableArrayListExtra(EXTRA_HEADERS); int priority = intent.getIntExtra(EXTRA_PRIORITY, PRIORITY_NORMAL); enqueue(url, filePath, headers, priority); break; } case ACTION_NETWORK: { int network = intent.getIntExtra(EXTRA_NETWORK_ID, NETWORK_ALL); setAllowedNetwork(network); break; } case ACTION_LOGGING: { boolean enabled = intent.getBooleanExtra(EXTRA_LOGGING_ID, true); setLoggingEnabled(enabled); break; } case ACTION_PROCESS_PENDING: { startDownload(); break; } case ACTION_QUERY: { long queryId = intent.getLongExtra(EXTRA_QUERY_ID, DEFAULT_EMPTY_VALUE); int queryType = intent.getIntExtra(EXTRA_QUERY_TYPE, QUERY_ALL); int status = intent.getIntExtra(EXTRA_STATUS, DEFAULT_EMPTY_VALUE); query(queryType, queryId, id, status); break; } case ACTION_PRIORITY: { int priority = intent.getIntExtra(EXTRA_PRIORITY, PRIORITY_NORMAL); setRequestPriority(id, priority); break; } case ACTION_RETRY: { retry(id); break; } case ACTION_REMOVE_ALL: { removeAll(); break; } case ACTION_CONCURRENT_DOWNLOADS_LIMIT: { int limit = intent.getIntExtra(EXTRA_CONCURRENT_DOWNLOADS_LIMIT, DEFAULT_DOWNLOADS_LIMIT); setDownloadsLimit(limit); break; } case ACTION_UPDATE_REQUEST_URL: { String url = intent.getStringExtra(EXTRA_URL); updateRequestUrl(id, url); break; } default: { startDownload(); break; } } } }); } }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
private void onSendMultipleAction(Intent intent, String resourcePath) { if (intent.hasExtra(Intent.EXTRA_STREAM)) { ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); for (Parcelable item : list) { Uri uri = (Uri) item;//ww w. j ava 2 s . co m UpDownServiceHelper.upload(this, uri, resourcePath, false); } } }
From source file:com.android.contacts.ContactSaveService.java
private void createRawContact(Intent intent) { String accountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME); String accountType = intent.getStringExtra(EXTRA_ACCOUNT_TYPE); String dataSet = intent.getStringExtra(EXTRA_DATA_SET); List<ContentValues> valueList = intent.getParcelableArrayListExtra(EXTRA_CONTENT_VALUES); Intent callbackIntent = intent.getParcelableExtra(EXTRA_CALLBACK_INTENT); ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(); operations.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) .withValue(RawContacts.ACCOUNT_NAME, accountName).withValue(RawContacts.ACCOUNT_TYPE, accountType) .withValue(RawContacts.DATA_SET, dataSet).build()); int size = valueList.size(); for (int i = 0; i < size; i++) { ContentValues values = valueList.get(i); values.keySet().retainAll(ALLOWED_DATA_COLUMNS); operations.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) .withValueBackReference(Data.RAW_CONTACT_ID, 0).withValues(values).build()); }// w w w. j a v a 2 s . c o m ContentResolver resolver = getContentResolver(); ContentProviderResult[] results; try { results = resolver.applyBatch(ContactsContract.AUTHORITY, operations); } catch (Exception e) { throw new RuntimeException("Failed to store new contact", e); } Uri rawContactUri = results[0].uri; callbackIntent.setData(RawContacts.getContactLookupUri(resolver, rawContactUri)); deliverCallback(callbackIntent); }