By registering the receiver in either app context / manifest file, would I be saved from not having constantly run my service in background ? Bcos I also know that charging / discharging thru usb / power supply would occur once a day or may once in 2 days and it doesn't make sense to keep a constantly monitoring when the phone is connected for charging / disconnected from charger. If something lets my service know that charger has been connected / disconnected, within my OnReceive, I can check what intent.getAction it is and then take a correct action accordingly.
Pls suggest. Thanks Omkar On May 2, 6:58 pm, srihari babu <[email protected]> wrote: > register this receiver with application context. > That would solve ur problem. > > second possible solution is that register receiver in manifest file. > > Regards, > Srihari.R > > On May 2, 1:06 pm, Omkar <[email protected]> wrote: > > > > > Hi, > > I have created a activity to show battery information when > > started, but I would preferably want to keep it constantly running in > > the background as a service and make a log of when the charging > > started, when it ended, how long the battery charge lasted etc etc. > > If I keep it in activity, user must run this app when charging is > > started, which isn't make it much useful. I am not sure how do I set > > my app to trigger automatically when charging is started, disconnected > > etc. > > Btw, I have created a broadcastreceiver for catching > > Intent.ACTION_BATTERY_CHANGED and its working fine, but only from the > > activity. > > > Pls suggest what change should I be doing to my app, so that whenever > > there is a charging / discharging change thru charger plugin / usb > > plugin, my app shld log it in file. > > > Thanks > > Omkar- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

