Fixes issue #998.

Fixes multiple issues with the way PR #997 was implemented. 
@TShapinsky better to use android's [`Handler`](https://developer.android.com/reference/android/os/Handler.html) directly.