ParcelableCodeGenerator

If you are used to coding Android applications, there is a good chance that you had to write some Parcelable classes.

A quick reminder about Parcelable : It’s an interface you can implement on your classes. If you do so, you can then store the whole class in a Bundle or as an Intent extra.
My webservice library, DataDroid, use Parcelable objects to retrieve the result from the webservices if you don’t use a Database to store your data.

There is one downside with Parcelable … You need to write a LOT of boilerplate to implement the Parcelable interface in your class. And as every good software engineer, I’m lazy :D
Which brings us to ParcelableCodeGenerator !!

You can find all the information on its GitHub page, but here is a short explanation :

  • You clone the repository and import the Java project in Eclipse (or your favorite IDE)
  • You write a JSON file defining your Parcelable class in the input folder (you can use subfolders to sort your files). Examples are provided to learn the syntax
  • You run the project as a Java Project
  • The corresponding classes are “magically” generated in the output folder ready for you to copy them in your project

It’s really easy to use and it’s going to save you a lot of time.

Last important thing : the project license. As all my other projects, it is released under the Beerware license :

You can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.

DataDroid v2 is available !!!

The version 2 of DataDroid is finally available !

What’s new ?

  • A better architecture of the library which reduce a lot the boilerplate the developer has to write (you can check this article to see the difference)
  • A more robust and easier to use API for your network connections based on HTTPUrlConnection.
  • New features in the network connection API : HTTP authentication and possibility to disable SSL validation.
  • Automatic generation of a valid Android User-Agent for your requests
  • Better management of calling multiple requests at the same time in your Activitiess (It was possible in v1.0 but not easily enough).
  • The library works with API 8+ now (aka Froyo and future versions) which covers currently 97% of the user base, so it shouldn’t be a problem.
  • A lot more samples available.

For a complete presentation of the library, You can check this page.

The sample application has been updated on Google Play :



And as always the source code is available on GitHub

If you want to know how it works and how to use it in your application, go to the DataDroid website and you’ll find all the information you need

ContentProviderCodeGenerator or how to create your ContentProviders easily

There are multiple ways to store data persistently in Android, like for example the SharedPreferences. One of them is to use a ContentProvider.

A ContentProvider is one of primary building blocks of Android applications, providing content to applications. You can for example use it to open some of your data to other applications.
You can also use it to just store your data and not export it to other applications (by setting the flag android:exported="false" in your Android Manifest).

Write your first ContentProvider can be a challenging task as there are a good number of methods to implement and it’s not always clear how to do it.
That was one of the reason why I released with DataDroid (my local and remote data management library) some skeletons explaining how to do it by just following a bunch of TODOs to follow.

However you still have a lot of code to write, most of it just being copy/paste all over the classes. And when you start having multiple versions of your ContentProvider with new columns or tables, it begins to be really annoying to have to maintain that…

Which brings us to ContentProviderCodeGenerator !!

Like every lazy software engineer, it was bothering me and so I took/found some time and wrote a code generator ! :)

You can find all the information on its GitHub page, but here is a short explanation :

  • You clone the repository and import the Java project in Eclipse (or your favorite IDE)
  • You write a JSON file defining your tables and their columns in the input folder. Examples are provided to learn the syntax
  • You run the project as a Java Project
  • All the needed files are “magically” generated in the output folder ready for you to copy them in your project

It’s really easy to use (and if needed I can help you)
It makes adding a column or a table so easy it’s not even funny.
It just works. (yes I know I just used an Apple slogan on an Android blog) (and if it doesn’t work, I’ll fix it)

Last important thing : the project license. As all my other projects, it is released under the Beerware license :

You can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.

TimePickerDialog and AM/PM vs 24 Hour format

Just a short article to maybe help other people not spend 1 hour searching the web for the answer like I did.

The Android SDK provides you with 2 really well made dialog pickers for respectively a date and a time : DatePickerDialog and TimePickerDialog.

The constructors for DatePickerDialog are pretty much straight-forward.
However the one for TimePickerDialog has a small problem :

As you can see in the screenshot above, you need to specify through the is24HourView parameter whether you want to display a time with hours from 0 to 23 (used in France and Germany for example) or you want to display a time with hours from 1 to 12 and also AM/PM selector (used in the USA for example).

The main problem is that I don’t want to choose that in my code. I want it to be linked to the user locale settings like everythink else.
I don’t want why it was coded like that but here is how to link this parameter to the user locale :

    new TimePickerDialog(this, mOnTimeSetListener, time.hour, time.minute, DateFormat.is24HourFormat(this));

The method is24HourFormat from DateFormat allows us to retrieve the user setting.

Android + LEGO = Win ?

Update 08/07/2012 : After 24 hours, the project has already reached 2600+. 1/4 of the task is already done ! Now we just need to continue to talk about it so we reached rapidly the 10 000 mark ! :D

For the past years, I have been a developer as well as a huge fan of Android. I also have always played with LEGO (when I was young and even still now)

What if we could combine these 2 worlds ?!

That’s what Marc Young must have been thinking when he started his project !

This project looks awesome with even rotating arms, heads and antennas. And frankly I want one for myself ! :D

There is only one problem… This project is part of the CUUSOO system which is a way for people to present project to LEGO for future creation.
And before an idea can be valid, it needs to receive 10 000 votes.

So it would be great if you could vote for this project (it’s really fast and easy to do).

Page optimized by WP Minify WordPress Plugin