Questions tagged [parcelable]

parcelable refers to the capability of an object to be converted to a parcel, a container for reading and writing data of various type, using type specific rather than generic serialization

parcelable is defined in the Android API as as interface for classes whose instances can be written to and restored from a parcel

References

1664 questions
35
votes
2 answers

Arraylist in parcelable object

I have seen many parcelable examples so far, but for some reason I can't get it to work when it gets a bit more complex. I have a Movie object, which implements Parcelable. This book object contains some properties, such as ArrayLists. Running my…
Wesley
  • 979
  • 3
  • 11
  • 18
35
votes
2 answers

Companion Objects in Kotlin Interfaces

I am trying to make a interface Parcelable, as such I need a interface like this interface AB : Parcelable { companion object { val CREATOR : Parcelable.Creator } } and my two classes A and B looking like data class A (...):…
mickstar
  • 363
  • 1
  • 3
  • 5
34
votes
6 answers

Pass ArrayList to Activity

I have searched a few topics but not found a solution to my problem. public class Series implements Parcelable { private String name; private int numOfSeason; private int numOfEpisode; /** Constructors and Getters/Setters have been removed to make…
Adrian Jandl
  • 2,985
  • 4
  • 23
  • 30
34
votes
5 answers

ClassNotFoundException when unmarshalling: android.support.v4.view.ViewPager$SavedState

I am seeing the following error in my Android crash reports: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v4.view.ViewPager$SavedState at android.os.Parcel.readParcelable(Parcel.java:1971) at…
user1509445
  • 351
  • 1
  • 3
  • 5
34
votes
5 answers

what is difference between Parcelable and Serialization used in android

I want to know exact , whether should I used parcelable or serialization technique for sending data from one activity to other? is it compulsory to use one of them for sending data from one to other? when should I use them? and the exact…
SRam
  • 2,832
  • 4
  • 45
  • 72
33
votes
4 answers

Android, How to use readTypedList method correctly in a Parcelable class?

I have two Activities, in the first one, I instanciate an ArrayList of Object myObject. In the second activity, i need to get this Arraylist. I've found a tutorial : http://prasanta-paul.blogspot.com/2010/06/android-parcelable-example.html I have…
Gen
  • 403
  • 2
  • 6
  • 9
32
votes
4 answers

Help with passing ArrayList and parcelable Activity

So I've been googling most of yesterday and last nite and just can't seem to wrap my head around how to pass an arraylist to a subactivity. There are tons of examples and snippets passing primitive data types, but what I have is an arraylist of type…
wufoo
  • 13,571
  • 12
  • 53
  • 78
30
votes
4 answers

Android Parcelable and Serializable

So i know it is recommended to use Parcelable instead of Serializable in android, because it is faster. My question is: is that impossible to avoid using Serializable right? If I have a custom object i want to serialize, let's say I have the…
user1118019
  • 3,819
  • 8
  • 40
  • 46
30
votes
3 answers

Safe Args: use list of parcelables

I am using the Safe Args plugin with the new Navigation components for my Android project. Now I have an argument that is an array list of parcelables, is there a way to use this with the Safe Args Plugin? Something like app:argType=ParcelableArray.…
botflot
  • 275
  • 1
  • 4
  • 9
29
votes
4 answers

Android Class Parcelable with ArrayList

I have an android project where I have a class. In that class is an ArrayList. I will be getting some XML, parsing it out, then making objects out of it which I will be passing to another activity. I'm choosing Parcelable for this. Is…
Kenny
  • 2,124
  • 3
  • 33
  • 63
29
votes
2 answers

Reading and writing integer array to parcel

I could not find any solution for how to treat with integer array in case of parcel (I want to use these two functions dest.writeIntArray(storeId); and in.readIntArray(storeId);). Here is my code public class ResponseWholeAppData implements…
Atul Bhardwaj
  • 6,647
  • 5
  • 45
  • 63
28
votes
1 answer

Nested parcelable object not reading

I'm trying to parcel an object which contains some string/int variables and an object variable. The strings and int's are working, but not the nested object. I understand I would have to it also parcelable, but I'm apparently doing something wrong=.…
iomartin
  • 3,149
  • 9
  • 31
  • 47
28
votes
3 answers

ClassNotFoundException when unmarshalling and really don't know why

FIXED: ANSWER AT BOTTOM I am writing an android app for a project and im trying to use parcelable objects. I have 2 parcalable classes. The first is a normal class with only 2 arguments. The second one is a class with additional attributes and a…
Christian Risch
  • 301
  • 1
  • 3
  • 6
26
votes
4 answers

Kotlin parcelable and arrayList of parcelables

I am trying to write a parcelable data object to pass to from activityA to activityB in my android application. My object is passing with all the data, except my arraylist of the class Available Service data class AvailableService(val id: Int, …
JozeRi
  • 3,219
  • 6
  • 27
  • 45
26
votes
6 answers

Parcelable protocol requires a Parcelable.Creator object called CREATOR (I do have CREATOR)

I am trying to pass Parcelable data from one intent to another and this is the error I am getting: 08-31 14:12:22.709: E/AndroidRuntime(9931): FATAL EXCEPTION: main 08-31 14:12:22.709: E/AndroidRuntime(9931): java.lang.RuntimeException: Unable to…
Guy
  • 6,414
  • 19
  • 66
  • 136