android.content.Intent.putParcelableArrayListExtra()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(306)

本文整理了Java中android.content.Intent.putParcelableArrayListExtra()方法的一些代码示例,展示了Intent.putParcelableArrayListExtra()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.putParcelableArrayListExtra()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:putParcelableArrayListExtra

Intent.putParcelableArrayListExtra介绍

暂无

代码示例

代码示例来源:origin: androidannotations/androidannotations

public I parcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
  intent.putParcelableArrayListExtra(name, value);
  return (I) this;
}

代码示例来源:origin: pockethub/PocketHub

/**
 * Add extra field data value to intent being built up
 *
 * @param fieldName
 * @param value
 * @return this builder
 */
public Builder add(String fieldName, ArrayList<? extends Parcelable> value) {
  intent.putParcelableArrayListExtra(fieldName, value);
  return this;
}

代码示例来源:origin: aa112901/remusic

@Override
  public void onClick(View v) {
    Intent intent = new Intent(mContext, SelectActivity.class);
    intent.putParcelableArrayListExtra("ids", mList);
    mContext.startActivity(intent);
  }
});

代码示例来源:origin: aa112901/remusic

@Override
  public void onClick(View v) {
    Intent intent = new Intent(mContext, SelectActivity.class);
    intent.putParcelableArrayListExtra("ids", (ArrayList) mList);
    mContext.startActivity(intent);
  }
});

代码示例来源:origin: aa112901/remusic

@Override
  public void onClick(View v) {
    Intent intent = new Intent(mContext, SelectActivity.class);
    intent.putParcelableArrayListExtra("ids", mList);
    mContext.startActivity(intent);
  }
});

代码示例来源:origin: aa112901/remusic

@Override
  public void onClick(View v) {
    Intent intent = new Intent(mContext, SelectActivity.class);
    intent.putParcelableArrayListExtra("ids", (ArrayList) mList);
    mContext.startActivity(intent);
  }
});

代码示例来源:origin: aa112901/remusic

@Override
  public void onClick(View v) {
    Intent intent = new Intent(mContext, SelectActivity.class);
    intent.putParcelableArrayListExtra("ids", mList);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    mContext.startActivity(intent);
  }
});

代码示例来源:origin: aa112901/remusic

@Override
  public void onClick(View v) {
    Intent intent = new Intent(mContext, PlaylistSelectActivity.class);
    intent.putParcelableArrayListExtra("ids", arraylist);
    intent.putExtra("playlistid", playlistId);
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    mContext.startActivity(intent);
  }
});

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files.");
intent.setType("image/jpeg"); /* This example is sharing jpeg images. */

ArrayList<Uri> files = new ArrayList<Uri>();

for(String path : filesToSend /* List of the files you want to send */) {
  File file = new File(path);
  Uri uri = Uri.fromFile(file);
  files.add(uri);
}

intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
startActivity(intent);

代码示例来源:origin: cymcsg/UltimateAndroid

/**
 * Launch a new activity with ArrayList data.
 *
 * @param context
 * @param classes
 * @param key
 * @param value
 */
public static void sendIntent(Context context, Class classes, String key, ArrayList<? extends Parcelable> value) {
  Intent intent = new Intent();
  intent.setClass(context, classes);
  intent.putParcelableArrayListExtra(key, value);
  context.startActivity(intent);
}

代码示例来源:origin: stackoverflow.com

public static void email(Context context, String emailTo, String emailCC,
  String subject, String emailText, List<String> filePaths)
{
  //need to "send multiple" to get more than one attachment
  final Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
  emailIntent.setType("text/plain");
  emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, 
    new String[]{emailTo});
  emailIntent.putExtra(android.content.Intent.EXTRA_CC, 
    new String[]{emailCC});
  emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 
  emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);
  //has to be an ArrayList
  ArrayList<Uri> uris = new ArrayList<Uri>();
  //convert from paths to Android friendly Parcelable Uri's
  for (String file : filePaths)
  {
    File fileIn = new File(file);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
  }
  emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
  context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}

代码示例来源:origin: cymcsg/UltimateAndroid

/**
 * Launch a new activity with one ArrayList data and one pair of String data.
 *
 * @param context
 * @param classes
 * @param key
 * @param value
 * @param anotherKey
 * @param anotherValue
 */
public static void sendIntent(Context context, Class classes, String key, ArrayList<? extends Parcelable> value, String anotherKey, String anotherValue) {
  Intent intent = new Intent();
  intent.setClass(context, classes);
  intent.putParcelableArrayListExtra(key, value);
  intent.putExtra(anotherKey, anotherValue);
  context.startActivity(intent);
}

代码示例来源:origin: Rukey7/MvpApp

public static void launch(Context context, ArrayList<BeautyPhotoInfo> datas, int index) {
  Intent intent = new Intent(context, BigPhotoActivity.class);
  intent.putParcelableArrayListExtra(BIG_PHOTO_KEY, datas);
  intent.putExtra(PHOTO_INDEX_KEY, index);
  intent.putExtra(FROM_LOVE_ACTIVITY, false);
  context.startActivity(intent);
  ((Activity)context).overridePendingTransition(R.anim.expand_vertical_entry, R.anim.hold);
}

代码示例来源:origin: hidroh/materialistic

public static Intent makeSendIntentChooser(Context context, Uri data) {
  // use ACTION_SEND_MULTIPLE instead of ACTION_SEND to filter out
  // share receivers that accept only EXTRA_TEXT but not EXTRA_STREAM
  return Intent.createChooser(new Intent(Intent.ACTION_SEND_MULTIPLE)
          .setType("text/plain")
          .putParcelableArrayListExtra(Intent.EXTRA_STREAM,
              new ArrayList<Uri>(){{add(data);}}),
      context.getString(R.string.share_file));
}

代码示例来源:origin: ACRA/acra

/**
 * Builds an email intent with attachments
 *
 * @param subject         the message subject
 * @param body            the message body
 * @param attachments     the attachments
 * @return email intent
 */
@NonNull
protected Intent buildAttachmentIntent(@NonNull String subject, @Nullable String body, @NonNull ArrayList<Uri> attachments) {
  final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
  intent.putExtra(Intent.EXTRA_EMAIL, new String[]{mailConfig.mailTo()});
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.putExtra(Intent.EXTRA_SUBJECT, subject);
  intent.setType("message/rfc822");
  intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
  intent.putExtra(Intent.EXTRA_TEXT, body);
  return intent;
}

代码示例来源:origin: Rukey7/MvpApp

public static void launchForResult(Fragment fragment, ArrayList<BeautyPhotoInfo> datas, int index) {
  Intent intent = new Intent(fragment.getContext(), BigPhotoActivity.class);
  intent.putParcelableArrayListExtra(BIG_PHOTO_KEY, datas);
  intent.putExtra(PHOTO_INDEX_KEY, index);
  intent.putExtra(FROM_LOVE_ACTIVITY, true);
  fragment.startActivityForResult(intent, CommonConstant.REQUEST_CODE);
  fragment.getActivity().overridePendingTransition(R.anim.expand_vertical_entry, R.anim.hold);
}

代码示例来源:origin: guardianproject/haven

private void shareEvent ()
{
  String title = "Phoneypot: " + mEvent.getStartTime().toLocaleString();
  //need to "send multiple" to get more than one attachment
  final Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
  emailIntent.setType("text/plain");
  emailIntent.putExtra(Intent.EXTRA_SUBJECT, title);
  emailIntent.putExtra(Intent.EXTRA_TEXT, generateLog());
  //has to be an ArrayList
  ArrayList<Uri> uris = new ArrayList<>();
  //convert from paths to Android friendly Parcelable Uri's
  for (EventTrigger trigger : mEvent.getEventTriggers())
  {
    // ignore triggers for which we do not have valid file/file-paths
    if (trigger.getMimeType() == null || trigger.getPath() == null)
      continue;
    File fileIn = new File(trigger.getPath());
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
  }
  emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
  startActivity(Intent.createChooser(emailIntent, getString(R.string.share_event_action)));
}

代码示例来源:origin: zhihu/Matisse

Intent result = new Intent();
ArrayList<Uri> selectedUris = (ArrayList<Uri>) mSelectedCollection.asListOfUri();
result.putParcelableArrayListExtra(EXTRA_RESULT_SELECTION, selectedUris);
ArrayList<String> selectedPaths = (ArrayList<String>) mSelectedCollection.asListOfString();
result.putStringArrayListExtra(EXTRA_RESULT_SELECTION_PATH, selectedPaths);

代码示例来源:origin: robolectric/robolectric

@Test
public void testParcelableArrayListExtra() {
 Intent intent = new Intent();
 Parcelable parcel1 = new TestParcelable(22);
 Parcelable parcel2 = new TestParcelable(23);
 ArrayList<Parcelable> parcels = new ArrayList<>();
 parcels.add(parcel1);
 parcels.add(parcel2);
 assertSame(intent, intent.putParcelableArrayListExtra("foo", parcels));
 assertSame(parcels, intent.getParcelableArrayListExtra("foo"));
 assertSame(parcel1, intent.getParcelableArrayListExtra("foo").get(0));
 assertSame(parcel2, intent.getParcelableArrayListExtra("foo").get(1));
 assertSame(parcels, intent.getExtras().getParcelableArrayList("foo"));
}

代码示例来源:origin: firebase/firebase-jobdispatcher-android

@Test
public void prepareJob() {
 Intent intent = new Intent();
 Bundle encode = encodeContentUriJob(getContentUriTrigger(), TestUtil.JOB_CODER);
 intent.putExtra(GooglePlayJobWriter.REQUEST_PARAM_EXTRAS, encode);
 Parcel container = Parcel.obtain();
 container.writeStrongBinder(new Binder());
 PendingCallback pcb = new PendingCallback(container);
 intent.putExtra("callback", pcb);
 ArrayList<Uri> uris = new ArrayList<>();
 uris.add(ContactsContract.AUTHORITY_URI);
 uris.add(Media.EXTERNAL_CONTENT_URI);
 intent.putParcelableArrayListExtra(BundleProtocol.PACKED_PARAM_TRIGGERED_URIS, uris);
 JobInvocation jobInvocation = receiver.prepareJob(intent);
 assertEquals(jobInvocation.getTriggerReason().getTriggeredContentUris(), uris);
}

相关文章

Intent类方法