Questions tagged [parcel]

In Android, a Parcel is a container for a message (data and object references). It's a high-performance alternative to Java's standard serialization.

This should not be confused with That Parcel is an application bundler for HTML, CSS, and Js

537 questions
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
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
68
votes
8 answers

Android E/Parcel﹕ Class not found when unmarshalling (only on Samsung Tab3)

I've been unable to resolve why this error occurs, and only on a Samsung Tab3 device, running 4.4.2? It happens when my MainActivity starts another Activity, and passes a Parcelable class in the intent like so: private void…
59
votes
5 answers

How to use Parcel in Android?

I'm trying to use Parcel to write and then read back a Parcelable. For some reason, when I read the object back from the file, it's coming back as null. public void testFoo() { final Foo orig = new Foo("blah blah"); // Wrote orig to a…
emmby
  • 99,783
  • 65
  • 191
  • 249
56
votes
4 answers

"BadParcelableException: ClassNotFoundException when unmarshalling " while using Parcel.read method that has a ClassLoader as argument

Given a custom class org.example.app.MyClass implements Parcelable, I want to write a List to a Parcel. I did the marshalling with List myclassList = ... parcel.writeList(myclassList); whenever I try to unmarshall the class…
Flow
  • 23,572
  • 15
  • 99
  • 156
48
votes
2 answers

How to marshall and unmarshall a Parcelable to a byte array with help of Parcel?

I want to marshall and unmarshall a Class that implements Parcelable to/from a byte array. I am well aware of the fact that the Parcelable representation is not stable and therefore not meant for long term storage of instances. But I have a use case…
Flow
  • 23,572
  • 15
  • 99
  • 156
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
26
votes
4 answers

How to solve Eslint - Module.createRequire is not a function error?

I'm using react app with Parcel bundler & TypeScript. I'm trying to use ESLint but I get this error: ESLint: Initialization error (ESLint). Module.createRequire is not a function. versions: IDE: Webstorm Node Version: 16.6.2 NPM Version: 7.20.3 I…
Netanel Vaknin
  • 856
  • 2
  • 8
  • 21
22
votes
5 answers

Error: Unable to deserialize cloned data due to invalid or unsupported version

I use parcel to deploy my web projects and on one occasion I got this error below while trying to deploy the page. I tried several solutions I saw online but none worked for me, I didn't even understand some. Error: Unable to deserialize cloned data…
David.E
  • 511
  • 2
  • 4
  • 13
21
votes
7 answers

Parcel Unmarshalling unknown type code

We are getting this error in the Crash reports logged by play store. Cant replicate this in all our testing. Does anyone else have the same problem or solution ? Thing is, we dont even know what to do to replicate this bug. All Parcelable objects…
ManiacalG
  • 221
  • 1
  • 2
  • 7
19
votes
4 answers

Is it possible to parcel a generic class?

I'm trying to create public class MyClass implements Parcelable. I'm having trouble implementing Parcelable. Is it possible to create a generic class that implements Parcelable? (Note that T is bounded so that it also must…
Andre Gregori
  • 1,150
  • 1
  • 10
  • 17
17
votes
2 answers

What is the use of flags in Parcelable?

I have been writing Parcelables 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
Manish Kumar Sharma
  • 12,982
  • 9
  • 58
  • 105
16
votes
2 answers

Android Parcelable in Kotlin: CREATOR not found on Parcelable data class

With the release of the Kotlin RC, I started writing an app to learn it however I can not figure out how to get Parcelable to work. the data class: data class Project (val reponame:String, val username:String, val…
Eggman87
  • 571
  • 5
  • 12
14
votes
2 answers

How To: Parcel a bitmap in Android

I have a serialized class which I want to add a bitmap to, but Bitmap doesn't support serialize. Instead I thought I'd use a parcel instead, but can't get it to work. Here's some test code using local variables: Parcel parcel; Bitmap…
FrinkTheBrave
  • 3,894
  • 10
  • 46
  • 55
14
votes
1 answer

How to parcel value with type Any? using @Parcelize

I have encountered with a problem when trying to put value with type Any? into parcel. I'm using @Parcelize from kotlinx.android.parcel. Lint is warning me and hints with message to add @RawValue, but it's not helping. I…
Skullper
  • 714
  • 5
  • 22
1
2 3
35 36