Parcelable array not passing between activities - android

So, I'm having an issue with passing a Parcelable array between two activities. For some reason, the app blows up before it even loads the activity I'm calling.
Here is the object I am trying to pass.
import android.os.Parcel;
import android.os.Parcelable;
public class Inventory implements Parcelable{
public String inventory_id = "" ;
public String vin = "" ;
public String stock = "" ;
public String new_used = "" ;
public String certified = "" ;
public String mileage = "" ;
public Inventory() {}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(inventory_id);
dest.writeString(vin);
dest.writeString(stock);
dest.writeString(new_used);
dest.writeString(certified);
dest.writeString(mileage);
}
public Inventory(Parcel source){
inventory_id = source.readString();
vin = source.readString();
stock = source.readString();
new_used = source.readString();
certified = source.readString();
mileage = source.readString();
}
public static final Parcelable.Creator<Inventory> CREATOR = new Parcelable.Creator<Inventory>() {
public Inventory createFromParcel(Parcel source) {
return new Inventory(source);
}
public Inventory[] newArray(int size) {
return new Inventory[size];
}
};
}
And here is the line where I pass it
Intent intent = new Intent(this, Activity2.class);
intent.putParcelableArrayListExtra("invList", invList); //This is a list of inventory objects.
startActivity(intent);
This code never loads Activity2. I can create a debug point in the onCreate method in Activity 2 and it is never called. If I comment out intent.putParcelableArrayListExtra("invList", invList);, Activity2 will load, but of course blows up when I get to the line that needs the invList, which leads me to believe that something is happening with the Parcelable objects between activities. I get nothing in my LogCat. It just reloads Activity1.
Any help here would be appreciated.

Related

Parcelable how to use the 'KEY' value when receiving all the information?

I'm making an Android application and I would like to send an ArrayList to the next Activity, but I don't know how to do this with Parcelable.
For example: I got an int named as ID and a String named as Names. I use JSON for getting all informations from PHP and MySQL.
In the for-loop I add all those Names and ID to a class. But then I don't know how to write all these Names and ID into a bundle.putParcelableArrayList(KEY, ArrayList...);, because I don't know how to do this with the KEY value. Do I need to give the KEY value numbers or is there automatically one KEY?
class alleDeelnemers implements Parcelable {
int id;
String name;
/* GETTER AND SETTER */
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(volgnummer);
}
public alleDeelnemers(Parcel in) {
volgnummer = in.readString();
id = in.readInt();
}
// Creator
public static final Parcelable.Creator CREATOR
= new Parcelable.Creator() {
public alleDeelnemers createFromParcel(Parcel in) {
return new alleDeelnemers(in);
}
public alleDeelnemers[] newArray(int size) {
return new alleDeelnemers[size];
}
};
}
Receiving data:
ArrayList<alleDeelnemers> deelnemers = new ArrayList<>();
for(int i=0; i < jArrayDeelnemer.length(); i++)
{
JSONObject json_data = jArrayDeelnemer.getJSONObject(i);
//class alleDeelnemers
deelnemer = new alleDeelnemers();
//ID
int ID = json_data.getInt("ID");
deelnemer.setId(ID);
//alle deelnemers
String name = json_data.getString("name ");
deelnemer.setName(name );
//toevoegen in de class
deelnemers.add(deelnemer);
}
error this line: deelnemer = new alleDeelnemers(); need to build a constructor.
The key is any name you would use to reference your ArrayList. Further in the started activity, you will use this key to retrieve the ArrayList. For example, in the initial activity, do
bundle.putParcelableArrayList("MY_ARRAY_LIST", deelnemers);
and then in the started activity, to retrieve it later
Bundle b = getIntent().getExtras();
ArrayList<alleDeelnemers> list = b.getParcelableArrayList("MY_ARRAY_LIST");
Note that the KEY used here is "MY_ARRAY_LIST". It is a better practice to use xml string constants or an interface for storing constant KEYS.
1.First create your alleDeelnemers class as Parcelable using plug-in
2 Sender Activity
Intent intent = new Intent(this, YourActivity.class);
intent.putExtra("mData", myArrayList);
3 Receiver Activity
myArrayList = getIntent().getParcelableExtra("mData")

java.lang.RuntimeException: Parcel android.os.Parcel: Unmarshalling unknown type code

I seem to be getting a strange error in my app (see GitHub), which occurs when I pass objects to different activities that implement Parcelable.
I have checked other questions and answers here on Stack Overflow, but I was unable to find a solution. I've tried the answer here, for example - here it is for reference:
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
I've also made sure that the method calls in writeToParcel are in order. Most other questions on Stack Overflow about this issue don't have answers.
Moreover, the reason I am asking a new question is because I think my problem is caused because of how I have used interfaces in my app (I will expand on this point later on). Other questions on Stack Overflow would not suit my particular scenario.
In the following, I have provided links to the code via GitHub, so that you can explore more of the code if required.
When I click on a button to launch a new activity (passing an object that implements Parcelable), there is a crash:
Process: com.satsuware.flashcards, PID: 4664
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.satsuware.flashcards/com.satsumasoftware.flashcards.ui.FlashCardActivity}: java.lang.RuntimeException: Parcel android.os.Parcel#d2219e4: Unmarshalling unknown type code 6815860 at offset 200
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
...
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel#d2219e4: Unmarshalling unknown type code 6815860 at offset 200
at android.os.Parcel.readValue(Parcel.java:2319)
at android.os.Parcel.readListInternal(Parcel.java:2633)
at android.os.Parcel.readArrayList(Parcel.java:1914)
at android.os.Parcel.readValue(Parcel.java:2264)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2592)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.Bundle.getParcelable(Bundle.java:786)
at android.content.Intent.getParcelableExtra(Intent.java:5377)
at com.satsumasoftware.flashcards.ui.FlashCardActivity.onCreate(FlashCardActivity.java:71)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
...
I call the aforementioned activity like so (also see GitHub):
Intent intent = new Intent(TopicDetailActivity.this, FlashCardActivity.class);
intent.putExtra(FlashCardActivity.EXTRA_TOPIC, mTopic);
intent.putExtra(FlashCardActivity.EXTRA_NUM_CARDS, mSelectedNumCards);
intent.putExtra(FlashCardActivity.EXTRA_CARD_LIST, mFilteredCards);
startActivity(intent);
The main part to consider is when I pass mTopic. This is a Topic interface that I created.
However, the Topic interface extends Parcelable and so the objects that implement Topic also include the constructor, CREATOR field, and the methods that a class implementing Parcelable would normally have to have.
You can view the relevant classes via the GitHub links, but I will provide the relevant parts of these classes below. Here is the Topic interface:
public interface Topic extends Parcelable {
int getId();
String getIdentifier();
String getName();
Course getCourse();
ArrayList<FlashCard> getFlashCards(Context context);
class FlashCardsRetriever {
public static ArrayList<FlashCard> filterStandardCards(ArrayList<FlashCard> flashCards, #StandardFlashCard.ContentType int contentType) {
ArrayList<FlashCard> filteredCards = new ArrayList<>();
for (FlashCard flashCard : flashCards) {
boolean isPaper2 = ((StandardFlashCard) flashCard).isPaper2();
boolean condition;
switch (contentType) {
case StandardFlashCard.PAPER_1:
condition = !isPaper2;
break;
case StandardFlashCard.PAPER_2:
condition = isPaper2;
break;
case StandardFlashCard.ALL:
condition = true;
break;
default:
throw new IllegalArgumentException("content type '" + contentType + "' is invalid");
}
if (condition) filteredCards.add(flashCard);
}
return filteredCards;
}
...
}
}
A class (object) that implements Topic:
public class CourseTopic implements Topic {
...
public CourseTopic(int id, String identifier, String name, Course course) {
...
}
#Override
public int getId() {
return mId;
}
#Override
public String getIdentifier() {
return mIdentifier;
}
...
protected CourseTopic(Parcel in) {
mId = in.readInt();
mIdentifier = in.readString();
mName = in.readString();
mCourse = in.readParcelable(Course.class.getClassLoader());
}
public static final Parcelable.Creator<CourseTopic> CREATOR = new Parcelable.Creator<CourseTopic>() {
#Override
public CourseTopic createFromParcel(Parcel in) {
return new CourseTopic(in);
}
#Override
public CourseTopic[] newArray(int size) {
return new CourseTopic[size];
}
};
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mId);
dest.writeString(mIdentifier);
dest.writeString(mName);
dest.writeParcelable(mCourse, flags);
}
}
In one of the last lines of the code above, you can see I pass mCourse, which is a Course object I created. Here it is:
public class Course implements Parcelable {
...
public Course(String subject, String examBoard, #FlashCard.CourseType String courseType,
String revisionGuide) {
...
}
public String getSubjectIdentifier() {
return mSubjectIdentifier;
}
public String getExamBoardIdentifier() {
return mBoardIdentifier;
}
public ArrayList<Topic> getTopics(Context context) {
ArrayList<Topic> topics = new ArrayList<>();
String filename = mSubjectIdentifier + "_" + mBoardIdentifier + "_topics.csv";
CsvParser parser = CsvUtils.getMyParser();
try {
List<String[]> allRows = parser.parseAll(context.getAssets().open(filename));
for (String[] line : allRows) {
int id = Integer.parseInt(line[0]);
topics.add(new CourseTopic(id, line[1], line[2], this));
}
} catch (IOException e) {
e.printStackTrace();
}
return topics;
}
...
protected Course(Parcel in) {
mSubjectIdentifier = in.readString();
mBoardIdentifier = in.readString();
mCourseType = in.readString();
mRevisionGuide = in.readString();
}
public static final Creator<Course> CREATOR = new Creator<Course>() {
#Override
public Course createFromParcel(Parcel in) {
return new Course(in);
}
#Override
public Course[] newArray(int size) {
return new Course[size];
}
};
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mSubjectIdentifier);
dest.writeString(mBoardIdentifier);
dest.writeString(mCourseType);
dest.writeString(mRevisionGuide);
}
}
I suspect something here may be causing the problem, and is the reason my scenario is different from those in other questions.
To be honest, I'm not exactly sure what may be causing the error, so explanations and guidance in answers would be much appreciated.
Edit:
After David Wasser's suggestions, I have updated parts of my code like so:
FlashCardActivity.java - onCreate(...):
Bundle extras = getIntent().getExtras();
extras.setClassLoader(Topic.class.getClassLoader());
mTopic = extras.getParcelable(EXTRA_TOPIC);
Course.java - writeToParcel(...):
dest.writeString(mSubjectIdentifier);
dest.writeString(mBoardIdentifier);
dest.writeString(mCourseType);
dest.writeInt(mRevisionGuide == null ? 0 : 1);
if (mRevisionGuide != null) dest.writeString(mRevisionGuide);
Course.java - Course(Parcel in):
mSubjectIdentifier = in.readString();
mBoardIdentifier = in.readString();
mCourseType = in.readString();
if (in.readInt() != 0) mRevisionGuide = in.readString();
I've added log messages using Log.d(...) to see if any variables are null when being passed in writeToParcel(...) and used David Wasser's method to properly handle this.
I still get the same error message, however.
Your problem is in LanguagesFlashCard. Here are your parcel/unparcel methods:
protected LanguagesFlashCard(Parcel in) {
mId = in.readInt();
mEnglish = in.readString();
mAnswerPrefix = in.readString();
mAnswer = in.readString();
mTier = in.readInt();
mTopic = in.readParcelable(Topic.class.getClassLoader());
}
As you can see, they don't match. The second item you write to the Parcel is an int, the second item you read from the Parcel is a String.
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mId);
dest.writeInt(mTier);
dest.writeString(mEnglish);
dest.writeString(mAnswerPrefix);
dest.writeString(mAnswer);
dest.writeParcelable(mTopic, flags);
}
Kotlin code for sub data class like ImagesModel also parcelable used
data class MyPostModel(
#SerializedName("post_id") val post_id: String? = "",
#SerializedName("images") val images: ArrayList<ImagesModel>? = null
): Parcelable {
constructor(parcel: Parcel) : this(
parcel.writeString(post_id)
parcel.createTypedArrayList(ImagesModel.CREATOR)
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(post_id)
parcel.writeTypedList(images)
}
}

Intent extras seem to get corrupted

Boy, this is a weird one.
I'm sending an intent to a service.
public void updatePortfolio(VehiclePortfolio vehiclePortfolio) {
GenericParcel gp = new GenericParcel(vehiclePortfolio);
Intent apiIntent = new Intent(context, ApiRequestService.class);
apiIntent.putExtra(Constants.ARG_REQUEST, Constants.REQUEST_UPDATE_PORTFOLIO);
apiIntent.putExtra(Constants.ARG_VEHICLE_PORTFOLIO, gp);
// Try getting object back here
//gp = apiIntent.getParcelableExtra(Constants.ARG_VEHICLE_PORTFOLIO);
VehiclePortfolio vp = (VehiclePortfolio)gp.getObject();
String s = apiIntent.getStringExtra(Constants.ARG_REQUEST);
vehiclePortfolio = (VehiclePortfolio) gp.getObject();
// .putExtra(Constants.ARG_VEHICLE_PORTFOLIO, b);
context.startService(apiIntent);
}
When I check the extras in the intent at the end of this function they look fine as shown below.
mMap HashMap (id=830037731672)
[0] HashMap$HashMapEntry (id=830037731800)
key "ARG_VEHICLE_PORTFOLIO" (id=830038543392)
value GenericParcel (id=830038204888)
o VehiclePortfolio (id=830038244704)
configuration VehicleConfiguration (id=830038258216)
id "1375379159508" (id=830038245672)
optionals VehiclePortfolio$_Fields[5] (id=830038244744)
priceReport VehiclePriceReport (id=830038312960)
quotes ArrayList (id=830038417704)
timestamp "2013-08-01T17:46:31.000Z" (id=830038536424)
[1] HashMap$HashMapEntry (id=830037731768)
key "ARG_REQUEST" (id=830037687416)
value Integer (id=830019251512)
value 6
Then, when the service receives the intent, this is what the extras look like. Notice that the vehiclePortfolio has been overwritten on top of ARG_REQUEST extra and the key and value have been swapped. (What?!?)
mMap HashMap (id=830038833832)
[0] HashMap$HashMapEntry (id=830039001656)
key VehiclePortfolio (id=830038934408)
configuration VehicleConfiguration (id=830038936272)
id "1375379159508" (id=830038936128)
optionals null
priceReport VehiclePriceReport (id=830038941176)
quotes ArrayList (id=830038963264)
timestamp "2013-08-01T17:46:31.000Z" (id=830039001424)
value "ARG_REQUEST" (id=830039001576)
[1] HashMap$HashMapEntry (id=830038834568)
key "ARG_VEHICLE_PORTFOLIO" (id=830038833888)
value GenericParcel (id=830038834512)
o Parcel (id=830037350528)
mNativePtr 1891558544
mOwnsNativeParcelObject true
mStack null
Below is the code for GenericParcel which I suspect to be the culprit. If I do a test and pass a string in place of the complex object inside a GenericParcel, behavior is as expected.
public class GenericParcel implements Parcelable {
private Object o;
public GenericParcel(Object in) {
o = in;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel out, int flags) {
out.writeValue(o);
}
public Object getObject() {
return o;
}
public static final Creator<GenericParcel> CREATOR = new Creator<GenericParcel>() {
public GenericParcel createFromParcel(Parcel source) {
return new GenericParcel(source);
}
public GenericParcel[] newArray(int size) {
return new GenericParcel[size];
}
};
}
I think your implementation of your Parcelable object is not correct. You should have a constructor that takes as its only argument a Parcel (not an Object) and you should be reading values from the Parcel in the same order you wrote them to the Parcel in writeToParcel().
public class GenericParcel implements Parcelable {
private Object o;
public GenericParcel(Parcel in) {
o = in.readValue(null);
}
#Override
public void writeToParcel(Parcel out, int flags) {
out.writeValue(o);
}
// the rest removed for brevity
}

Android Bundle corrupted when passing between activities?

I'm trying to pass an ArrayList of Parcelable objects plus a string value between two activities. This is the code to add the data to the intent and pass it through:
Intent intent = new Intent(this, DisplayLotListActivity.class);
Bundle dataBundle = new Bundle();
dataBundle.putParcelableArrayList(DisplayLotListActivity.EXTRA_LOT_ARRAY, lotList);
dataBundle.putString(EXTRA_LOT_NUMBER, lotNumber);
intent.putExtra(DisplayLotListActivity.EXTRA_DATA, dataBundle);
startActivity(intent);
This is the code that I'm using to get the data out of the intent on the target activity:
Intent intent = getIntent();
Bundle dataBundle = intent.getBundleExtra(EXTRA_DATA);
lotList = dataBundle.getParcelableArrayList(EXTRA_LOT_ARRAY);
lotNumber = dataBundle.getString(LotInquiryActivity.EXTRA_LOT_NUMBER);
When I check the debugger the data structures look correct before the activity is called but when I get into the target activity the data structure has been corrupted. Specifically the ArrayList as 3 elements and it is still 3 elements in size but the second element is null. There is then an additional extra in the bundle which contains the missing element object with a null key. I have images of the debugger before and after but can't put them in the post because of anti-spam rules.
Before: http://i.stack.imgur.com/vDipq.png
After: http://i.stack.imgur.com/JqbF7.png
Is there something I'm missing? This issue occurs whether I use a Bundle or add the ArrayList directly to the intent. This is being run on a Samsung Tab 2 running 4.0.3. This also occurs with a 4.0 emulator.
[Edit]
This is the Parcelable object being used (I've just left the getter and setter methods off the bottom)
public class Lot implements Parcelable{
private String lotn;
private String dsc1;
private String dsc2;
private String litm;
private long itm;
private String locn;
private String mcu;
private String uom1;
private String uom2;
private BigDecimal pqav;
private BigDecimal pqoh;
private BigDecimal sqoh;
private long vend;
private String rlot;
private String ldsc;
private String lots;
private String lot1;
private String lot2;
private String lot3;
private String lotsdsc;
private XMLGregorianCalendar mmej;
private XMLGregorianCalendar ohdj;
public Lot(){
}
public Lot(Parcel source){
lotn = source.readString();
dsc1 = source.readString();
dsc2 = source.readString();
litm = source.readString();
locn = source.readString();
mcu = source.readString();
uom1 = source.readString();
uom2 = source.readString();
itm = source.readLong();
pqav = new BigDecimal(source.readString());
pqoh = new BigDecimal(source.readString());
sqoh = new BigDecimal(source.readString());
vend = source.readLong();
rlot = source.readString();
ldsc = source.readString();
lots = source.readString();
lot1 = source.readString();
lot2 = source.readString();
lot3 = source.readString();
lotsdsc = source.readString();
try{
mmej = DatatypeFactory.newInstance().newXMLGregorianCalendar(source.readString());
}catch (Exception exc){
mmej = null;
}
try{
ohdj = DatatypeFactory.newInstance().newXMLGregorianCalendar(source.readString());
}catch (Exception exc){
ohdj = null;
}
}
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(lotn);
dest.writeString(dsc1);
dest.writeString(dsc2);
dest.writeString(litm);
dest.writeString(locn);
dest.writeString(mcu);
dest.writeString(uom1);
dest.writeString(uom2);
dest.writeLong(itm);
if(pqav != null){
dest.writeString(pqav.toPlainString());
} else {
dest.writeString("0");
}
if(pqoh != null){
dest.writeString(pqoh.toPlainString());
} else {
dest.writeString("0");
}
if(sqoh != null){
dest.writeString(sqoh.toPlainString());
} else {
dest.writeString("0");
}
dest.writeLong(vend);
dest.writeString(rlot);
dest.writeString(ldsc);
dest.writeString(lots);
dest.writeString(lot1);
dest.writeString(lot2);
dest.writeString(lot3);
dest.writeString(lotsdsc);
if(mmej != null){
dest.writeString(mmej.toXMLFormat());
} else {
dest.writeString("");
}
if(ohdj != null){
dest.writeString(ohdj.toXMLFormat());
} else {
dest.writeString("");
}
}
/**
*
*/
public static final Parcelable.Creator<Lot> CREATOR
= new Parcelable.Creator<Lot>() {
public Lot createFromParcel(Parcel in) {
return new Lot(in);
}
public Lot[] newArray(int size) {
return new Lot[size];
}
};
OK, for anyone that comes back to this question there's two problems that I found which I assume combined to cause this behavior. The issues all related to the Parcelable object I was using so thanks to Todd for at least pointing me in this direction.
Firstly, I had a simple error where I had missed a readString() in my constructor of the Parcelable object. So basically I was writing out n elements and reading in n - 1 elements. The second issue is that Android does not implement the javax.xml.datatype library which means that XMLGregorianCalendar is not available. As I didn't need the features of this class on the client side (there's a Java Web Application that it talks to which does use it) I just converted over to a simple java.util.Date object instead.

When passing 2 identical Parcable Classes, 1 is null

i have a weird issue.
I'm trying to pass 2 parcable classesfrom one activity to another.
I define both of them the exact same way, but of them is null.
The parcable class :
class Friends implements Parcelable {
private ArrayList<Integer> ids = new ArrayList<Integer>();
private ArrayList<String> names = new ArrayList<String>();
private ArrayList<Bitmap> images = new ArrayList<Bitmap>();
public void addId(Integer id)
{
ids.add(id);
}
public void addName(String name){
names.add(name);
}
public void addImage(Bitmap img){
images.add(img);
}
public ArrayList<Integer> getIds() {
return ids;
}
public ArrayList<String> getNames() {
return names;
}
public ArrayList<Bitmap> getImages() {
return images;
}
#Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeList(ids);
dest.writeList(names);
dest.writeList(images);
}
public static final Parcelable.Creator<Friends> CREATOR = new Parcelable.Creator<Friends>() {
public Friends createFromParcel(Parcel in) {
return new Friends(in);
}
public Friends[] newArray(int size) {
return new Friends[size];
}
};
public Friends(Parcel in){
in.readList(ids, null);
in.readList(names, null);
in.readList(images, null);
}
public Friends(Integer id, String name, Bitmap img) {
ids.add(id);
names.add(name);
images.add(img);
}
public Friends(){
}
The Sending part :
for(Integer position : selectedIds)
{
String name = a.getItem(position).getFriendName();
int id = a.getItem(position).getFriendId();
Bitmap img = a.getItem(position).getFriendImage();
Log.e("ID",String.valueOf(id));
selectedFriends.addId(new Integer(id));
selectedFriends.addName(name);
selectedFriends.addImage(img);
}
for(int position=0;position<list.getCount(); position++)
{
String name = a.getItem(position).getFriendName();
int id = a.getItem(position).getFriendId();
Bitmap img = a.getItem(position).getFriendImage();
Log.e("All IDs",String.valueOf(id));
allFriends.addId(new Integer(id));
allFriends.addName(name);
allFriends.addImage(img);
}
b.putParcelable("selecet_friends", selectedFriends);
b.putParcelable("all_friends", allFriends);
data.putExtras(b);
Both of the loops are being runned ( i can see the logs), all variables you don't see are being initialized correctly, everything is fine.
The Reciving part :
i define both as null :
private Friends selectedFriends = null;
private Friends allFriends = null;
And handle the onResult like this :
Log.e("Result","yessss");
Friends all_friends = (Friends)data.getParcelableExtra("all_friends");
Friends selected_friends = (Friends)data.getParcelableExtra("selected_friends");
allFriends = all_friends;
selectedFriends = selected_friends;
if(selectedFriends != null){
Log.e("is null","No");
}
if(allFriends != null){
Log.e("is all null","No");
}
Does anyone know how come the selectedFriends is null when allFriends is not?
EDIT:
Just a thought, but maybe it's because i put 2 parcables on a Bundle?
just i just add 2 bundles?
In the sending method you have a typo in this line:
b.putParcelable("selecet_friends", selectedFriends);
try this instead:
b.putParcelable("selected_friends", selectedFriends);
Also, you should use more specific names for the keys. The documentation for putExtras() says:
Add a set of extended data to the intent. The keys must include a
package prefix, for example the app com.android.contacts would use
names like "com.android.contacts.ShowAll

Categories

Resources