简体   繁体   中英

Pass Custom array Data to another activity via intent

     final RecipientEditTextView emailRetv =
      (RecipientEditTextView) findViewById(R.id.email_retv);
      emailRetv.setTokenizer(new Rfc822Tokenizer());
       emailRetv.setAdapter(new BaseRecipientAdapter(this));
       DrawableRecipientChips[] chips = phoneRetv.getSortedRecipients();

I need to send DrawableRecipientChips[] chips to another activity via intents. please how do i go about?.

DrawableRecipientChips[] chips is from this libary

If you have complex objects that you need to pass from one Activity to another, you don't have to put them in the Intent . You can just put them in public static variables, like this:

in ActivityA :

public static DrawableRecipientChips[] chips;

in ActivityB.onCreate() :

// Get reference to the chips array from the previous Activity
chips = ActivityA.chips;

This isn't a perfect solution, because if Android kills your process and the user returns to the app, the public static variable will be null. But you can test for that case and then restart your app from the beginning if this happens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM