parcelable

adding parcelable to an interface class for custom objects

依然范特西╮ 提交于 2019-12-05 06:17:48
I have a custom object class but that is implemented through an inteface, how can i incorporate parceable in it. I have followed and searched about parceable, but it is only for object class. eg : How can I make my custom objects Parcelable? I want to pass my object list to another activity in android. code : public interface Projection { interface Job { @XBRead("./task") List<Task> getTasks(); @XBRead("./id") String getid(); @XBRead("./job_title") String getjob_title(); @XBRead("./job_description") String getjob_description(); @XBRead("./job_room") String getjob_room(); @XBRead("./status")

How to find source of crashes of type java.lang.RuntimeException: Parcel android.os.Parcel@####: Unmarshalling unknown type code XXXX at offset YYY

时光总嘲笑我的痴心妄想 提交于 2019-12-05 04:46:50
Our crash reporting system is logging crashes of this type: Caused by java.lang.RuntimeException: Parcel android.os.Parcel@8bf0d1f: Unmarshalling unknown type code 6881391 at offset 356 at android.os.Parcel.readValue(Parcel.java:2779) at android.os.Parcel.readSparseArrayInternal(Parcel.java:3148) at android.os.Parcel.readSparseArray(Parcel.java:2362) at android.os.Parcel.readValue(Parcel.java:2757) at android.os.Parcel.readArrayMapInternal(Parcel.java:3067) at android.os.BaseBundle.unparcel(BaseBundle.java:257) at android.os.Bundle.getSparseParcelableArray(Bundle.java:958) at android.support

Parcelable inheritance: abstract class - Which CREATOR?

心已入冬 提交于 2019-12-05 03:35:53
I have an abstract class A which implements Parcelable. I have a class B and a class C who both extend A . How can I make them parcelable? Of cause I could chain it and provide a CREATOR both in A and B like suggested in many posts. But since I have other Objects who store the A-B-C classes and implement Parcelable themselfes, that approach seems not to be working because when I want to pass an ArrayList of A I would have to use the CREATOR in the typed list by ArrayList<A> elements = new ArrayList<>(); in.readTypedList(elements , B.CREATOR); // B.CREATOR? C.CREATOR??? Which obviously makes no

Put Object as intent for next activity

旧时模样 提交于 2019-12-05 01:20:46
Is it possible to to put an object of type Object into an intent as a Extra? I have a variable of type object and won't know until it is assigned a value as to what the object datatype is. Maybe something to do with serialization or as a bundle i'm not sure? And then in the next activity how do I then get this value in order to store it in an ArrayList<Object> ? Rich Schuler Bundle by way of Intent#putExtra does not have any function to add an Object . You can only pass in a Parcelable or a Serializable object. Any object you want to pass via an Intent must implement one of those interfaces.

What is the use of flags in Parcelable?

一笑奈何 提交于 2019-12-05 00:20:19
I have been writing Parcelable s to Parcel without any focus on flags field, which is a parameter in the method signature and it has worked fine but I have run into an implementation where I can no longer ignore them: public static <K extends Parcelable, V extends Parcelable> void write(Parcel dest, Map<K, V> map, int flags) { if (map == null) { dest.writeInt(-1); } else { Set<Map.Entry<K, V>> entrySet = map.entrySet(); dest.writeInt(entrySet.size()); for (Map.Entry<K, V> entry : entrySet) { dest.writeParcelable(entry.getKey(), flags); dest.writeParcelable(entry.getValue(), flags); } } } This

Does retrieving a parcelable object through bundle always create new copy?

喜欢而已 提交于 2019-12-04 17:22:07
问题 I'm passing a parcelable object to a fragment by adding into a bundle while creating the fragment. In onc instance modification to this parcelled object reflects modification in original object and in another case it is not. I'm a little baffled by this behaviour. Till now I have assumed retrieving a parcelled objects through a bundle always create new object[no sure whether it's shallow copy or deep copy]. Someone please clarify parcelable behaviour. 回答1: I was struggling with a similar

Passing ArrayList<CustomObject> Between Activities

落爺英雄遲暮 提交于 2019-12-04 13:24:50
问题 i've implemented a Parcelable class: public class Evento implements Parcelable { private int; private String ; private String imagen; //more atts //Constructors, setters and getters public Evento(Parcel in) { this.id = in.readInt(); this.titulo = in.readString(); this.imagen=in.readString(); public void writeToParcel(Parcel dest, int flags) { dest.writeInt(id); dest.writeString(titulo); dest.writeString(imagen); } public static final Parcelable.Creator<Evento> CREATOR = new Parcelable.Creator

Is using Parcelable the right way to send data between applications?

☆樱花仙子☆ 提交于 2019-12-04 12:15:34
问题 I am trying to understand how to communicate between applications in Android - not just between Activity instances. I set up a 'client' that sends a Messenger obj to a Service (in the Intent sent to the service); the service creates a Message obj and sends it back to the 'client' using messenger.send(message) . This works fine until I try to use the Message.obj to hold an object. I created my own Parcelable class MyParcelable in the service and put it into the message. All works until the

Intent and Parcelable object Android

守給你的承諾、 提交于 2019-12-04 12:01:09
问题 Why do I need to parcel my object even if I just need to send it to another thread of the same task? Actually I need to open an activity that will run even on the same thread (the main thread). In other words why didn't Google provide a version of startActivity that take a generic object ad parameteer instead of a bundle to let me start an activity in case I know it is within the same process or (most of the times) even the same thread (the main one)? 回答1: You don't need to use Parcelable to

How to read and write Enum into parcel on Android?

夙愿已清 提交于 2019-12-04 08:02:02
问题 Here is my model class: public enum Action { RETRY, SETTINGS } private int imageId; private String description; private String actionName; private Action action; public NetworkError(int imageId, String description, String actionName, Action action ) { this.imageId = imageId; this.description = description; this.actionName = actionName; this.action = action; } public int getImageId() { return imageId; } public void setImageId(int imageId) { this.imageId = imageId; } public String