parcelable

Using Parcelable with circular references

It appears that Parcelable doesn't gracefully handle circular references like Serializable does. In the following example, the Serialization of Bar works just fine, but writing it to a Parcel causes a stackoverflow: I/TestRunner( 1571): java.lang.StackOverflowError I/TestRunner( 1571): at android.os.Parcel.writeParcelable(Parcel.jav...

Writing arrays of Parcelables to a Parcel in Android

I'm trying to write an array of objects that implement Parcelable into a Parcel using writeParcelableArray. The objects I'm trying to write are defined (as you'd expect) as: public class Arrival implements Parcelable { /* All the right stuff in here... this class compiles and acts fine. */ } And I'm trying to write them into a ...

Problem unmarshalling parcelables.

I've got a few classes that implement Parcelable and some of these classes contain each other as properties. I'm marshalling the classes into a Parcel to pass them between activities. Marshalling them TO the Parcel works fine, but when I try to unmarshall them I get the following error: ... AndroidRuntime E Caused by: android.os.BadPa...

Android, Serializable/Parcelable problem in client-server app

I want to send complex data from my android to a remote server via TCP-sockets. I know that I need to serialize the Objects. In Android this is done via parcelable. But this is an android specific interface and the server only knows the serializable interface. Also vice-versa android doesn't know a serializable interface. Both the andro...

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

Hi, In my activity , I create a Bitmap object, and 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)? Thank you. ...

Android app resets on orientation change, best way to handle?

So I am making a basic chess app to play around with some various elements of android programming and so far I am learning a lot, but this time I am lost. When the orientation of the emulator changes the activity gets reset. Based on my research the same thing will happen anytime the application is paused/interrupted, ie. keyboard chang...

How to use Parcelable if class requires additional parameters in construcor

Hi All, I'm trying to create class with generics that will have ability to serialize its state using Parcelable interface. The problem is that class has to contain constructor with single parameter - Parcel, but in my case I need to create class with additional parameters. Besides, Parcelable.Creator doesn't allow to use generics. Here ...

Put an object in Handler message

Hi! I need to download an image from the internet, in a different thread, and then send that image object in the handler message, to the UI thread. I already have this: ... Message msg = Message.obtain(); Bundle b = new Bundle(); b.putParcelable("MyObject", (Parcelable) object); msg.setData(b); handler.sendMessage(msg); And ...

Question about parcelable object

Hi, I want to save a list of Parcelable Restaurant objects on onSaveInstanceState. I created a Restaurant class extending Parcelable and a RestaurantList object, both shown below. In my main activity I fill my RestauranList directly from json internet data using GSON: restaurantList = gson.fromJson(r, RestaurantList.class); Now, when...

Why is the parcelable object null in receiving activity?

I am following the Parcelable example in the Android developer guide with the intention of having a more complex object that I send to different activities. Right now, my class is a wrapper of a String member. If I put the object in the intent and read it back from the Intent it reads as expected, however, on the receiver side, it is ...

Problem in implementing Parcelable containing other Parcelable

I'm implementing Parcelable class that has another Parcelable insde. In OuterParcelable class: @Override public void writeToParcel(Parcel dest, int flags) { Bundle tmp = new Bundle(); tmp.putParcelable("innerParcelable", mParcelable); dest.writeBundle(tmp); and then: public OuterParcelable(Parcel parcel) { super(); ...

Is it possible to create a HashMap that is Parcelable on Android?

I am trying to extend HashMap as a Parcelable and I got the syntax to compile, however, at runtime it throws an exception and returns a null pointer trying to un-marshal the data. The sender has to cast to (Parcelable) to resolve ambiguity, however, the receiver complains that is expected Parcelable but found HashMap. Has anyone been s...

Does a serializable object always get serialized when put in a bundle?

We were wondering if when using Bundle with serializable or parcelable objects, when does the marshalling actually happen? As soon as you put it in the bundle? Since bundles are mostly used to simply pass around data between two screens (we're not even talking about IPC here!), there doesn't seem to be much point in marshalling an object...

Sending an Object to a library class in Android

I'm attempting to make a simple homebrew game engine/framework in android. I have the "engine" as a library project that handles all of the graphics rendering, game activity, and whatnot. Essentially, the library project has a class GameMain which has a background image, an array of drawables, and a few functions (the most important is a...

Is using Serializable in Android bad?

Hello, I've been reading a lot of posts and articles extolling the speed of Parcelable over Serializable. I've been using both for a while to pass data between Activities through Intents, and have yet to notice any speed difference when switching between the two. The typical amount of data I have to transfer is 5 to 15 nested objects wi...

How to pass an array of Address objects to an other Acitvity

Hi I'm trying to pass an array of Address objects to another Activity through an Intent object. As the Address class implements the Parcelable interface I try to do the following. I got a List Address object from a Geocoder object, which I convert into a array of Address objects. Then I put this array into the Intent and call the acti...

How to send an ArrayList of custom objects in a Bundle

I have an application that uses a service to create an ArrayList of custom objects (MyObject) every x seconds. I then want my Activity to obtain this ArrayList. I'm currently planning on having the Service send a message to the Activity's handler every time it finishes the query for the data. I want the message to the Handler to conta...

Make Class Parcelable error

I am trying to make Task parcelable to put into an bundle to pass from my service to activity but I'm having a little bit of trouble working with the ArrayList of my custom type. Task: @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel prc, int ar...

Custom Parcelable object passed to core

I want to send a broadcast message with intent within extra data of my custom type which implements Parcelable. In more details: I want to create a shortcut on the HS However system does not accept object of my custom Command type, error message: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.solvek.us...

Efficiency of Parcelable for inproc communication

I want to pass a huge object (e.g. Bitmap) from one activity to another inside one process. If I put it into the Bundle like Parcelable, will Android really serialize the object or pass it by reference? ...