简体   繁体   English

(本机)如何在本机反应中检测电池电量?

[英](react-native) How to detect the battery level in react native?

I need to get the battery level. 我需要获取电池电量。 If the level is low based upon that i have to show the optimised components. 如果基于此水平较低,则必须显示优化的组件。 Is there a way to detect the battery level like network connection ? 有没有办法像网络连接那样检测电池电量?

I think you're going to need to use a plugin or write a native module for this. 我认为您需要为此使用插件或编写本机模块。

https://github.com/oojr/react-native-battery is an example. https://github.com/oojr/react-native-battery是一个示例。

The list of available react native API's are on the left hand side at the bottom of the dock, it looks like none expose any power or battery for now. 可用反应本地API的列表位于扩展坞底部的左侧,看起来现在没有任何电源或电池。

https://facebook.github.io/react-native/docs/actionsheetios.html https://facebook.github.io/react-native/docs/actionsheetios.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM