[英]Android development with sensor accelerometer and brightness
I'm developing an app that uses the sensor accelerometer.我正在开发一个使用传感器加速度计的应用程序。 I want the display to go black for instance when a value reach 8.1 and go back to normal when 7 is reached.
例如,当值达到 8.1 时,我希望显示器变黑,并在达到 7 时恢复正常。 Is it possible without using screen brightness?
是否可以不使用屏幕亮度? I want it to be complete black and this is not possible what i know with screen brightness.
我希望它是全黑的,而我所知道的屏幕亮度是不可能的。
Hope I gave enough information.希望我提供了足够的信息。
Try this in your activity.在你的活动中试试这个。 Let your main.xml load a black image -
让您的 main.xml 加载黑色图像 -
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Since you also need the screen to be black while you are using other apps.由于您在使用其他应用程序时还需要屏幕为黑色。 Then you need to write a background service that receives the accelerometer values and when it reaches 8.1, you can use the above snippet of code in your service.
然后你需要编写一个接收加速度计值的后台服务,当它达到 8.1 时,你可以在你的服务中使用上面的代码片段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.