parcelable

Passing Parcelable Object between Intents

☆樱花仙子☆ 提交于 2019-12-11 04:59:32
问题 I am having an issue passing an object I have created in between events. I used the website http://www.parcelabler.com/ to create the parcelable element of the code. The object class is show below: (The Item class is another simple object containing Strings and doubles and has also been made parcelable) import android.os.Parcel; import android.os.Parcelable; import java.util.ArrayList; public class Diner implements Parcelable { private String name; private ArrayList<Item> itemList = new

Android parcelable and Intent: redBundle: bad magic number

会有一股神秘感。 提交于 2019-12-11 04:51:27
问题 I have an array list of objects and I am using this example to get this arrayList from one activity to another activity: http://androidideasblog.blogspot.in/2010/02/passing-list-of-objects-between.html Here is a part of my code: Activity 1: Intent myIntent = new Intent(context, JournalArticles.class); Bundle b = new Bundle(); b.putParcelableArrayList("articles", articles); myIntent.putExtras(b); startActivityForResult(myIntent,0); Activity 2: Bundle b = this.getIntent().getExtras(); ArrayList

Error when implementing Parcelable in android

前提是你 提交于 2019-12-11 04:24:32
问题 The following class implements Parcelable class package mobile.bh.classes; import java.util.ArrayList; import java.util.List; import mobile.bh.activities.MethodStep; import android.content.Context; import android.graphics.Bitmap; import android.os.Parcel; import android.os.Parcelable; //simple class that just has one member property as an example public class Recipe implements Parcelable { public int id; public String name; public List<Ingredient> ingredients; public List<MethodStep> method;

how to pass an object containing with drawable parameter to another activity through intent using Parcelable Interface In android

谁说胖子不能爱 提交于 2019-12-11 04:15:41
问题 I want to pass an object containing a drawable field using Parcelable Inteface to another Activity. But problem is, in public void writeToParcel(Parcel parcel, int flags) overridden method in class(whose object has to send), I can't have "parcel.writeDrawable" kind of method. So other fields I'm able to pass, but not Drawable. I have added the following methods in my class after implementing Parcelable Interface. public static final Parcelable.Creator<ImageInfo> CREATOR = new Parcelable

Parcel, ClassLoader and Reading Null values

穿精又带淫゛_ 提交于 2019-12-11 03:56:59
问题 I am trying to understand how to read null values from Parcel properly. Let's look my use case: public class MyModel implements Parcelable { private Long id; private String name; public MyModel() {} public MyModel(Parcel in) { readFromParcel(in); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeValue(id); dest.writeValue(name); } public void readFromParcel(Parcel in) { id = (Long) in.readValue(Long.class

Android implement Parcelable object which has hashmap

♀尐吖头ヾ 提交于 2019-12-11 02:40:06
问题 I have classes like this. public class RateData { Map<String, List<RateDTO>> rateMap; } public class RateDTO { private String code; private String name; private String value; } Now I need parcelable this RateData class. I think we can not parcel this rateMap as normal variable. Please give me an example how to do this. 回答1: You should make DateRTO Parcelable - this should be trivial. Then, Map<String, List<RateDTO>> map; public void writeToParcel(Parcel out, int flags) { out.writeInt(map.size

Sending data from activity to fragment using set methods

被刻印的时光 ゝ 提交于 2019-12-10 20:24:19
问题 I've posted a question regarding of passing data from activity to a fragment. And I've learnt that implementing Parcelable to a POJO class is a right way of doing it. After some research I also understand that in order to pass data to a fragment should use Bundle instead of Intent. My previous question --> Using same fragments but different content in Android But now, my question is, what should I do in order to display a list of details (name, address, phone) using set methods when the

Send object across process throws Class not found when unmarshalling

放肆的年华 提交于 2019-12-10 19:09:04
问题 I'm coding and android app which have 2 process, One is obviously the main process which handle all the UI things and other stuffs and the other process hosts a service that handles network(socket) listening and other things. To communicate across the two process, I use the Messenger approach, and works great until I need to send custom java objects. This java class implements the Parcelable interface, which allows Messenger to send java object across process boundaries. Here is an exmple of

Using Parcelable to pass highly nested classes between Activities

不打扰是莪最后的温柔 提交于 2019-12-10 18:49:52
问题 Suppose I want to store a custom object of type MyObject in an Intent . The way to do this is to make MyObject implement Parcelable . If one of the fields of MyObject is also a custom object of type Widget the obvious thing to do is to make Widget implement Parcelable too. The trouble is that there is a huge amount of boilerplate involved when implementing Parcelable . You can get around this by not making Widget implement Parcelable but instead just giving it a constructor taking a Parcel

Is parcelable object passed through bundle same as original one?

拜拜、爱过 提交于 2019-12-10 17:33:32
问题 This is something that has bothered me for a while now. If we have some kind of Parcelable object in our activity and we pass it to fragment using Bundle, I've always thought the object that we receive in fragment is actually a new object. However, after running some tests today, it seems the object in fragment is actually same as the object in activity. Is that correct? EDIT: Small clarification. I don't refer to object's values. I refer to the '==' comparison. 回答1: When you make your object