3

I want to generate a low battery alert programmatically, same as that will be generated when battery is low..can any one post a sample code how to do it..am aware of ACTION_BATTERY_LOW. but how to use it..? i want to generate a low battery alert even though battery is not low.

Mr_and_Mrs_D
  • 29,590
  • 35
  • 170
  • 347
Sri Sri
  • 3,037
  • 7
  • 31
  • 37

2 Answers2

3

ACTION_BATTERY_LOW is a system's broadcast action, so you won't be able to generate it for security reasons - at least not on a "regular" device

DonGru
  • 13,258
  • 8
  • 43
  • 55
  • Then is there is any other way to generate low battery alert Martin? – Sri Sri Sep 09 '10 at 11:15
  • I don't exactly know what you're trying to do - but if it's just about raising an alarm you could use ACTION_BATTERY_CHANGED to monitor the battery state and if it drops under a defined value you can show a custom low-battery-dialogue – DonGru Sep 09 '10 at 11:38
2

Try here: http://androidcommunity.com/forums/f8/battery-value-in-andriod-22236/

dorin
  • 875
  • 2
  • 15
  • 34