Refreshing the display from a widget?
<p>I am trying to set the screen brightness from a widget.  We know this is easily possible since tons of widgets do this already, but how.....</p>

<p>In a service I call from the widget I do this to set the brightness:</p>

<pre><code>Settings.System.putInt(this.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 200);
</code></pre>

<p>That works great except it does not "refresh" the screen to apply the new settings.  Turning the screen off and on does refresh the display settings, so we know that the code works.</p>

<p>I also read on several sites that something like this will refresh the screen, but we cannot use this since we are in a widget.  The widget activity and the service cannot use getWindow.</p>

<pre><code>WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100 / 100.0f;
getWindow().setAttributes(lp);
</code></pre>

<p>How else are all these widgets like Beautiful Widgets, Power control, Extended controls, etc doing this?</p>

<p>Update:
Another poster recommended kicking off an empty activity and executing the WindowManager refresh.  That works but it brings up an ugly black screen for a second.  Since the other widgets don't do this, there has to be a way to keep the ugly blank black screen from showing.</p>
