Add gradle build file.
Avoid calling getSystemService() and save it.
Merge pull request #4 from gipi/various-fixes

Various fixes