本文介绍了UiModeManager - 夜间模式(升级Froyo)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图关闭按钮的背光使用UiModeManager的夜间模式功能,我的申请。默认台钟的应用程序(的Nexus One)关闭时,它是灰色背光源,我想做到这一点为好。

I have been trying to turn off the backlight of the buttons in my application using the UiModeManager's nightmode function. The default Desk Clock application (Nexus One) turns off the backlight when it is dimmed, and I want to do this as well.

我用下面的code尝试:

I've tried using the following code:

UiModeManager经理=(UiModeManager)  getSystemService(UI_MODE_SERVICE);  mgr.setNightMode(UiModeManager.MODE_NIGHT_YES);

在UiModeManager.setNightMode(INT模式)文件说的:

The UiModeManager.setNightMode(int mode) documentation says this:

设定夜间模式。更改  夜间模式是唯一有效的当  汽车或桌面模式上启用  设备。

这是否意味着,该设备具有在物理的办公桌码头?我可以用UiModeManager.enableCarMode(INT标志)方法,该设备设置为汽车模式。这工作得很好,但它不关灯,只调暗屏幕背光。

Does that mean that the device has to be physically in a desk dock?I can set the device to car mode using the UiModeManager.enableCarMode(int flags) method. This works fine, but it doesn't turn off the lights, it only dims the screen's backlight.

有没有一种方法来设置设备进入台模式,不使用物理台码头?作为升级Froyo源$ C ​​$ C尚未发布,我不能看着集结在台时钟应用程序。

Is there a way to set the device into desk mode without using a physical desk dock? As the FroYo source code is not yet released, I cannot look at the build-in Desk Clock application.

推荐答案

回答我的问题为Froyo的源$ C ​​$ C刚刚发布:

Answering my own question as the Froyo source code has just been released:

我不认为你必须使用UIModeManager类。这是怎样的DeskClock应用程序做:

I don't think you have to use the UIModeManager class. This is how the DeskClock app does:

Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();

//Look at this!
winParams.buttonBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;

win.setAttributes(winParams);

..它为我的作品也是如此。

..And it works for me as well.

这篇关于UiModeManager - 夜间模式(升级Froyo)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 00:31