Just to be clear, I don’t like implementing additional serializing/deserializing code, but as it turns out, it’s pretty simple to implement it, and it improves performance. So why not? :)

To make your class Parcelable, you have to implement the following methods:

int describeContents();
void writeToParcel(Parcel dest, int flags);

And you have to define a public static field named CREATOR (that implements Parcelable.Creator<T>)

Just take a look this example:

import android.os.Parcel;
import android.os.Parcelable;
import java.util.Date;
public class ExampleParcelable implements Parcelable {
private String stringValue;
private Integer integerValue;
private char charValue;
private boolean boolValue;
private Date dateValue;
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(stringValue);
dest.writeInt(integerValue);
dest.writeInt(charValue); // yup, it's actually a char
dest.writeInt(boolValue ? 1 : 0); // can't store bools, but we can do it this way
dest.writeLong(dateValue.getTime()); // same here, can't write date's, but we can get time in long
}
// Added this default constructor in case you are using some JSON/XML whatever parsers that require no-arg constructor
public ExampleParcelable() { }
/**
Just to make life easier, I've added a constructor that creates our ExampleParcelable from a Parcel (of course, you don't have to do it that way)
*/
public ExampleParcelable(Parcel parcel) {
// The only important thing is to read them in the same
// order as you wrote them (take a look at writeToParcel)
stringValue = parcel.readString();
integerValue = parcel.readInt();
charValue = (char) parcel.readInt();
dateValue = new Date(parcel.readLong());
}
public static final Parcelable.Creator CREATOR = new Creator<UserContentInfo>() {
@Override
public ExampleParcelable createFromParcel(Parcel source) {
return new ExampleParcelable(source);
}
@Override
public ExampleParcelable[] newArray(int size) {
return new ExampleParcelable[0];
}
};
}

It’s pretty much straight forward. In writeToParcel method you need to write fields that you need (in case you don’t want to pass every field), and later in CREATOR’s createFromParcel read every field in the same order you’ve written to Parcel in the first place.

I’ve added an example how can you write, and later read char and date types. Because can’t write everything (but it can write other Parcelables in case you need it).

I just love it when you need something simple and easy that perfectly suits your needs. I needed some lightweight XML parser for iOS, and I found it.

To be honest (since I’m coming from java background), I didn’t quite fall in love with objective-c at first, and it seemed to be that I needed a lot more code to make some basic stuff work. For example XML parsing. NSXMLParser is ok, but it’s event driven (link #1, link #2). I wanted some dead simple DOM parser.

So the whole library is just two classes SMXMLElement and SMXMLDocument. To show you how simple it is to parse a file, here is a (reduced) snippet from my application:

This is my first post without any code, but I just had to express myself :)

Today I had my first non-JavaSvet presentation (for those who don’t know JavaSvet is the first serbian Java user group). It was organized by the great people in SEE ICT organization. I wasn’t the only speaker, a friend of mine Vladan Petrović was in it as well, and he made this awesome presentation in prezi (I’ve helped with the content, not that much with the overall design). You can find the presentation here.

Photo by Vladimir Trkulja

I must say that I am pretty impressed how fast it was to make a presentation, and how effective it looks like. I saw that some people in the audience were impressed. And also, this was my first time presenting something that is inside a browser, and not powerpoint/open(libre)office. So it was all pretty new for me.

The goal was to first explain android basics, and later give them some small exercises that they can work on. We decided to test them with a little bit of tic-tac-toe. We’ve showed all the basics with this little example that I have made (github link). In case you need it, you can find there some basic examples of activities, services, broadcast receivers and content provider. Basically all-in-one example. It’s a small, but functional mp3 player (actual song isn’t hosted @ github). To make things more geeky, I’ve selected Paranoid Android by Radiohead (OK Computer album), cool eh?

The thing that totally blew me away was that when I got back home, I’ve already had some facebook invites, and tweets, that people continued working on the example as their first project.

I would be the luckiest man if any of those guys keep on working, and if they can make some cash out of it, that would be more than amazing. So thumbs up for everybody :)