here is a simple full working example:

http://stackoverflow.com/a/17217167/1944063