Adding changes from Prasanna.

Taken from https://github.com/muzima/muzima-android/commit/ed65d77c811409d2e1bc88fa05c33a1e3df6453a.