Updated sample for improved compatibility with older Android versions.