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
417
votes
14 answers

How to read/write a boolean when implementing the Parcelable interface?

I'm trying to make an ArrayList Parcelable in order to pass to an activity a list of custom object. I start writing a myObjectList class which extends ArrayList and implement Parcelable. Some attributes of MyObject are boolean but Parcel…
grunk
  • 14,718
  • 15
  • 67
  • 108
410
votes
16 answers

Android: Difference between Parcelable and Serializable?

Why does Android provide 2 interfaces for serializing objects? Do Serializable objects interopt with Android Binder and AIDL files?
live2dream95
  • 5,829
  • 8
  • 27
  • 24
353
votes
11 answers

How can I make my custom objects Parcelable?

I'm trying to make my objects Parcelable. However, I have custom objects and those objects have ArrayList attributes of other custom objects I have made. What would be the best way to do this?
Jean Jimenez
  • 4,732
  • 5
  • 24
  • 37
171
votes
16 answers

Is there a convenient way to create Parcelable data classes in Android with Kotlin?

I'm currently using the excellent AutoParcel in my Java project, which facilitates the creation of Parcelable classes. Now, Kotlin, which I consider for my next project, has this concept of data classes, that automatically generate the equals,…
thalesmello
  • 3,301
  • 3
  • 20
  • 20
167
votes
10 answers

How can I pass a Bitmap object from one activity to another

In my activity, I create a Bitmap object and then I need to launch another Activity, How can I pass this Bitmap object from the sub-activity (the one which is going to be launched)?
michael
  • 106,540
  • 116
  • 246
  • 346
121
votes
11 answers

How to send objects through bundle

I need to pass a reference to the class that does the majority of my processing through a bundle. The problem is it has nothing to do with intents or contexts and has a large amount of non-primitive objects. How do I package the class into a…
ahodder
  • 11,353
  • 14
  • 71
  • 114
115
votes
6 answers

How to use @Parcelize now that kotlin-android-extensions is being deprecated?

How do I replace annotation class Parcelize from package kotlinx.android.parcel with @Parcelize which is not coming from the kotlin-android-extensions plugin?
vepzfe
  • 4,217
  • 5
  • 26
  • 46
103
votes
3 answers

Parcelable where/when is describeContents() used?

Does anyone know where/when this method of a Parcelable is called? @Override public int describeContents() { return 0; } It has to be overriden. But should I consider doing something useful with it?
cody
  • 6,389
  • 15
  • 52
  • 77
99
votes
9 answers

Benefit of using Parcelable instead of serializing object

As I understand, Bundle and Parcelable belongs to the way Android performs serialization in. It is used for example in passing data between activities. But I wonder, if there are any benefits in using Parcelable instead of classic serialization in…
Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103
80
votes
4 answers

Read & writing arrays of Parcelable objects

I have following class which reads and writes an array of objects from/to a parcel: class ClassABC extends Parcelable { MyClass[] mObjList; private void readFromParcel(Parcel in) { mObjList = (MyClass[]) in.readParcelableArray( …
User7723337
  • 11,857
  • 27
  • 101
  • 182
76
votes
5 answers

how to properly implement Parcelable with an ArrayList?

I am having trouble making my class Parcelable. The trouble is, I am trying to write to the parcel a member in the class which is an ArrayList object. The ArrayList is Serializable, and the objects (ZigBeeDev) in the list are…
gnychis
  • 7,289
  • 18
  • 75
  • 113
75
votes
5 answers

Android: How to pass Parcelable object to intent and use getParcelable method of bundle?

Why bundle has getParcelableArrayList, getParcelable methods; but Intent has only putParcelableArrayListExtra method? Can I transmit only object, not ArrayList of one element? Then, what is getParcelable for?
yital9
  • 6,544
  • 15
  • 41
  • 54
74
votes
10 answers

How to read and write Enum into parcel on Android?

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…
Figen Güngör
  • 12,169
  • 14
  • 66
  • 108
71
votes
5 answers

The getParcelableExtra method is deprecated

I am passing Parcelable data into an Intent and getting it out on the other end using the getParcelableExtra(name:) method. However, getParcelableExtra(name:) seems to be deprecated. How do I fix the deprecation warning? Alternatively, are there any…
Rabindra Khadka
  • 1,344
  • 1
  • 13
  • 23
69
votes
3 answers

Write a sub class of Parcelable to another Parcel

I have a class that implements Parcelable interface: class A implements Parcelable { } I have another class B that contains an A object as an instance variable. In the writeToPacel inside class B, I want to write object B to the Parcel: class B…
user4o01
  • 2,688
  • 4
  • 39
  • 54
1
2 3
99 100