List of usage examples for android.content Intent putParcelableArrayListExtra
public @NonNull Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value)
From source file:org.gnucash.android.ui.budget.BudgetAmountEditorFragment.java
private void saveBudgetAmounts() { if (canSave()) { ArrayList<BudgetAmount> budgetAmounts = (ArrayList<BudgetAmount>) extractBudgetAmounts(); Intent data = new Intent(); data.putParcelableArrayListExtra(UxArgument.BUDGET_AMOUNT_LIST, budgetAmounts); getActivity().setResult(Activity.RESULT_OK, data); getActivity().finish();//from w w w .j a v a 2s. com } }
From source file:eu.geopaparazzi.core.maptools.FeaturePagerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_goto) { gotoFeature();// w w w . j a v a 2s . co m } else if (item.getItemId() == R.id.action_image_browser) { Intent intent = new Intent(this, ResourceBrowser.class); String tableName = selectedFeature.getTableName(); SpatialVectorTable table = SpatialiteSourcesManager.INSTANCE.getTableFromFeature(selectedFeature); intent.putExtra(TABLENAME_EXTRA_MESSAGE, tableName); intent.putExtra(DBPATH_EXTRA_MESSAGE, selectedFeature.getDatabasePath()); intent.putExtra(ROWID_EXTRA_MESSAGE, selectedFeature.getId()); startActivity(intent); } else if (item.getItemId() == R.id.action_save) { int dirtyCount = 0; for (Feature feature : featuresList) { if (feature.isDirty()) { dirtyCount++; } } if (dirtyCount == 0) { finish(); } saveDataTask = new StringAsyncTask(this) { private Exception ex; @Override protected String doBackgroundWork() { try { saveData(); } catch (Exception e) { ex = e; } return ""; } @Override protected void doUiPostWork(String response) { if (ex != null) { GPLog.error(this, "ERROR", ex); GPDialogs.errorDialog(FeaturePagerActivity.this, ex, null); } Intent result = new Intent(); result.putParcelableArrayListExtra(FeatureUtilities.KEY_FEATURESLIST, (ArrayList<? extends Parcelable>) featuresList); FeaturePagerActivity.this.setResult(RESULT_OK, result); finish(); } }; saveDataTask.setProgressDialog(null, getString(R.string.saving_to_database), false, null); saveDataTask.execute(); } return super.onOptionsItemSelected(item); }
From source file:org.dvbviewer.controller.ui.HomeActivity.java
@Override public void channelSelected(List<Channel> chans, Channel chan, int position) { Intent channelListIntent = new Intent(this, ChannelListMultiActivity.class); channelListIntent.putParcelableArrayListExtra(Channel.class.getName(), (ArrayList<Channel>) chans); channelListIntent.putExtra(ChannelList.KEY_SELECTED_POSITION, position); startActivity(channelListIntent);// w w w . j a v a 2 s . c om }
From source file:com.bilibili.boxing_impl.ui.BoxingViewActivity.java
private void finishByBackPressed(boolean value) { Intent intent = new Intent(); intent.putParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA, mSelectedImages); intent.putExtra(EXTRA_TYPE_BACK, value); setResult(RESULT_OK, intent);// w w w . j a va 2s . com finish(); }
From source file:info.schnatterer.logbackandroiddemo.SendLogActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Get URIs for log files using android.support.v4.content.FileProvider */ ArrayList<Uri> uris = new ArrayList<>(); for (final File fileEntry : Logs.getLogFiles(this)) { // Don't recurse! if (!fileEntry.isDirectory()) { // Create content provider URI uris.add(FileProvider.getUriForFile(this, getString(R.string.authority_log_file_provider), fileEntry));// www . j a v a2 s.c o m } } final Intent email = new Intent(Intent.ACTION_SEND_MULTIPLE); email.setType("message/rfc822"); email.putExtra(Intent.EXTRA_EMAIL, new String[] { "a@b.c" }); email.putExtra(Intent.EXTRA_SUBJECT, getString(getApplicationInfo().labelRes)); email.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); email.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(email); finish(); }
From source file:org.thoughtcrime.securesms.ContactSelectionFragment.java
private void handleSelectionFinished() { final Intent resultIntent = getActivity().getIntent(); final List<ContactData> selectedContacts = contactsFragment.getSelectedContacts(); if (selectedContacts != null) { resultIntent.putParcelableArrayListExtra("contacts", new ArrayList<ContactData>(contactsFragment.getSelectedContacts())); }/*from ww w. j av a2 s. c o m*/ getActivity().setResult(RESULT_OK, resultIntent); //finish(); }
From source file:com.example.topnewgrid.choosephotos.choosephotos.photoviewer.photoviewerinterface.ViewPagerDeleteActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_pager_delete); mViewPager = (HackyViewPager) findViewById(R.id.view_pager); // this.files = this.getIntent().getStringArrayExtra(FILES); this.files = this.getIntent().getParcelableArrayListExtra(FILES); this.index = this.getIntent().getIntExtra(CURRENT_INDEX, 0); iniSize = files.size();/* w ww . ja v a 2s.co m*/ for (int i = 0; i < iniSize; i++) { remainIndexs.add(i); } Button btnBack = (Button) findViewById(R.id.btnBack); btnBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); remainToDelete(); intent.putIntegerArrayListExtra("deleteIndexs", deleteIndexs); intent.putParcelableArrayListExtra("files", files); setResult(RESULT_OK, intent); ViewPagerDeleteActivity.this.finish(); } }); btnDelete = (Button) findViewById(R.id.btnCheck); btnDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int position = mViewPager.getCurrentItem(); if (files.size() > 1) { files.remove(position); remainIndexs.remove(position); } else { files.remove(0); remainIndexs.remove(0); } mViewPager.setAdapter(new SamplePagerAdapter()); if (files.size() > 0) { if (position == files.size()) { mViewPager.setCurrentItem(position - 1); } else { mViewPager.setCurrentItem(position); } } else { Intent intent = new Intent(); remainToDelete(); intent.putIntegerArrayListExtra("deleteIndexs", deleteIndexs); setResult(RESULT_OK, intent); ViewPagerDeleteActivity.this.finish(); } } }); SamplePagerAdapter spAdapter = new SamplePagerAdapter(); mViewPager.setAdapter(spAdapter); mViewPager.setCurrentItem(index); }
From source file:arun.com.chromer.webheads.ui.context.WebHeadContextActivity.java
@OnClick(R.id.share_all) public void onShareAllClick() { final CharSequence[] items = new String[] { getString(R.string.comma_seperated), getString(R.string.share_all_list) }; new MaterialDialog.Builder(this).title(R.string.choose_share_method).items(items) .itemsCallbackSingleChoice(0, (dialog, itemView, which, text) -> { if (which == 0) { startActivity(Intent.createChooser( TEXT_SHARE_INTENT.putExtra(EXTRA_TEXT, getCSVUrls().toString()), getString(R.string.share_all))); } else { final ArrayList<Uri> webSites = new ArrayList<>(); for (Website website : websitesAdapter.getWebsites()) { try { webSites.add(Uri.parse(website.preferredUrl())); } catch (Exception ignored) { }/*from www . j a v a 2 s . c o m*/ } final Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, webSites); shareIntent.setType("text/plain"); startActivity(Intent.createChooser(shareIntent, getString(R.string.share_all))); } return false; }).show(); }
From source file:com.ibm.pi.beacon.PIBeaconSensorService.java
private void sendBeaconNotification(Collection<Beacon> beacons) { PILogger.d(TAG, "sending beacon notification message"); JSONObject payload = buildBeaconPayload(beacons); mPiApiAdapter.sendBeaconNotificationMessage(payload, new PIAPICompletionHandler() { @Override//from ww w . ja va 2s . c om public void onComplete(PIAPIResult result) { if (result.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { PILogger.e(TAG, result.toString()); } } }); // send beacons in range event to listener callback Intent intent = new Intent(PIBeaconSensor.INTENT_RECEIVER_BEACON_COLLECTION); intent.putParcelableArrayListExtra(PIBeaconSensor.INTENT_EXTRA_BEACONS_IN_RANGE, new ArrayList<Beacon>(beacons)); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
From source file:com.asksven.betterbatterystats.ShareDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction //ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light_Dialog); ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), BaseActivity.getTheme(getActivity())); AlertDialog.Builder builder = new AlertDialog.Builder(context); final ArrayList<Integer> selectedSaveActions = new ArrayList<Integer>(); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean saveAsText = sharedPrefs.getBoolean("save_as_text", true); boolean saveAsJson = sharedPrefs.getBoolean("save_as_json", false); boolean saveLogcat = sharedPrefs.getBoolean("save_logcat", false); boolean saveDmesg = sharedPrefs.getBoolean("save_dmesg", false); final String m_refFromName = ""; final String m_refToName = ""; if (saveAsText) { selectedSaveActions.add(0);// w w w. j a v a 2s.c o m } if (saveAsJson) { selectedSaveActions.add(1); } if (saveLogcat) { selectedSaveActions.add(2); } if (saveDmesg) { selectedSaveActions.add(3); } builder.setTitle("Title"); builder.setMultiChoiceItems(R.array.saveAsLabels, new boolean[] { saveAsText, saveAsJson, saveLogcat, saveDmesg }, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { // If the user checked the item, add it to the // selected items selectedSaveActions.add(which); } else if (selectedSaveActions.contains(which)) { // Else, if the item is already in the array, // remove it selectedSaveActions.remove(Integer.valueOf(which)); } } }) // Set the action buttons .setPositiveButton(R.string.label_button_share, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { ArrayList<Uri> attachements = new ArrayList<Uri>(); Reference myReferenceFrom = ReferenceStore.getReferenceByName(m_refFromName, getActivity()); Reference myReferenceTo = ReferenceStore.getReferenceByName(m_refToName, getActivity()); Reading reading = new Reading(getActivity(), myReferenceFrom, myReferenceTo); // save as text is selected if (selectedSaveActions.contains(0)) { attachements.add(reading.writeToFileText(getActivity())); } // save as JSON if selected if (selectedSaveActions.contains(1)) { attachements.add(reading.writeToFileJson(getActivity())); } // save logcat if selected if (selectedSaveActions.contains(2)) { attachements.add(StatsProvider.getInstance(getActivity()).writeLogcatToFile()); } // save dmesg if selected if (selectedSaveActions.contains(3)) { attachements.add(StatsProvider.getInstance(getActivity()).writeDmesgToFile()); } if (!attachements.isEmpty()) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachements); shareIntent.setType("text/*"); startActivity(Intent.createChooser(shareIntent, "Share info to..")); } } }).setNeutralButton(R.string.label_button_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Reference myReferenceFrom = ReferenceStore.getReferenceByName(m_refFromName, getActivity()); Reference myReferenceTo = ReferenceStore.getReferenceByName(m_refToName, getActivity()); Reading reading = new Reading(getActivity(), myReferenceFrom, myReferenceTo); // save as text is selected // save as text is selected if (selectedSaveActions.contains(0)) { reading.writeToFileText(getActivity()); } // save as JSON if selected if (selectedSaveActions.contains(1)) { reading.writeToFileJson(getActivity()); } // save logcat if selected if (selectedSaveActions.contains(2)) { StatsProvider.getInstance(getActivity()).writeLogcatToFile(); } // save dmesg if selected if (selectedSaveActions.contains(3)) { StatsProvider.getInstance(getActivity()).writeDmesgToFile(); } } }).setNegativeButton(R.string.label_button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // do nothing } }); // Create the AlertDialog object and return it return builder.create(); }