java - React Native - 如何保持屏幕开启?无博览会
问题描述
你需要让你的手机继续使用以更好地编码吗?
在MainActivity.java
我们通常有这个
文件: MainActivity.java
package com.client;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "client";
}
}
您可以添加一些行以使您的手机始终保持开启以更好地进行编码,这些行代码不会让您的手机唤醒。
解决方案:
package com.client;
import com.facebook.react.ReactActivity;
import android.os.Bundle;
import android.view.WindowManager;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "client";
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().
addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
解决方案
推荐阅读
- python - 斐波那契特定数字生成器python
- powerbi - 在评估行级安全表达式期间遇到错误
- android - 无法从 BroadcastReceiver 的上下文中获取主题属性
- lua - wireshark lua debug.getinfo 为零
- go - 消息不以魔术字节开头
- ruby - 当我指定不这样做时,为什么我的代码将单词大写?
- angular - 如何让 DataTable 从外部选择中选择/突出显示而不将焦点设置在数据表上?
- matlab - 如何在MATLAB中堆叠一系列图像
- nestjs - 如何使用 DTO 将响应设置为招摇响应中的数组
- firebase - Firebase 云功能未发布