I've been toying around with the Android 5.0 Lollipop APIs, when I came across Window#getStatusBarColor()
. However, this requires an instance of Window
say from an Activity
, so it can't be used in a background service. Is there a way for an app to detect the status bar color on Android 5.0?
Update:
As Nikola Despotoski mentioned, there is the createScreenCaptureIntent
method which could do the trick by "screen recording," and just checking the status bar region.
As it turns out, the return value of this method if passed to startActivityForResult
. The initial request is meant to be called from an Activity.
Even if the result was saved and passed to a Service, there would need to be some complex pattern to re-ask for permission every time it was needed. There also doesn't seem to be a synchronous way to obtain a Bitmap. In the background, this means always processing screen changes just to obtain a single pixel.