Android support (originally by @pekkanikander)