开发者

How can I get Battery information in my app?

开发者 https://www.devze.com 2023-02-02 12:56 出处:网络
I tried to use a receiver to get Information about battery when received a system broadcast, but it failed without doing anything.

I tried to use a receiver to get Information about battery when received a system broadcast, but it failed without doing anything.

Here is the code:

if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {//doing

1...

}

and in AndroidManifest.xml

<receiver android:name=".BroadCastR开发者_Go百科eceiver_battery">

<intent-filter>

<action android:name="android.intent.action.BATTERY_CHANGED" />

</intent-filter>

</receiver>


quasharou ,

I found this tutorial useful

Hope it helps .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号