刷新从插件的显示器? [英] Refreshing the display from a widget?

查看:137
本文介绍了刷新从插件的显示器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置从插件的屏幕亮度。我们知道这是容易做到,因为吨的小部件已经这样做了,但如何.....

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.....

在我从小部件叫我做这个设置亮度的服务:

In a service I call from the widget I do this to set the brightness:

Settings.System.putInt(this.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 200);

这伟大工程只是它不刷新屏幕应用新设置。打开屏幕关闭并不会刷新显示设置,所以我们知道,code ++工程。

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.

我也看了几个网站,像这样将刷新该页面,但我们不能用这个,因为我们是在一个小部件。的插件活性和服务不能使用getWindow

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.

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

否则怎么都是这些小部件一样美丽的小部件,功率控制,扩展控制,等等这样做呢?

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

更新: 另一个海报建议拉开空活动,执行的窗口管理器刷新。这一工程,但它带来了一个丑陋的黑色画面一秒钟。由于其他部件不这样做,必须有一种方法来保持丑陋黑屏无法显示。

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.

推荐答案

对于blackscreen,设置主题的活动,包括这样的:

For the blackscreen, set a theme on the activity, containing this:

<style name="Theme.Transparent" parent="android:Theme"> 
<item name="android:windowIsTranslucent">true</item> 
<item name="android:windowBackground">@color/transparent</item> 
<item name="android:windowContentOverlay">@null</item> 
<item name="android:windowNoTitle">true</item> 
<item name="android:windowIsFloating">true</item> 
<item name="android:backgroundDimEnabled">false</item> 
</style>

由于塞巴斯蒂安的答案,我在这里复制了。

Thanks Sebastian for the answer, I've copied it in here.

这篇关于刷新从插件的显示器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆