javascriptandroidiosmobile

Is it possible to access a mobile devices battery status or charge via a web browser API?


I've spend some time looking around to see if it is possible to access a mobile devices battery status or charge via a web browser API but haven't found any resources or really anything even discussing this topic. This makes me believe it's not possible as it isn't in the spec of whatever reason (security?).

Either way I've found that it is possible to get the battery status / charge percentage with iOS, Cordova, PhoneGap, Appcelerator etc.. all of which has an API I might be able to get to work might work for what I am looking into developing. However all of these solutions still would required the app to run as native app — I'm hoping to be able to run it in browser on the device.

Is this possible? If so, what browser API should I be looking into?


Solution

  • Thanks Tapani and Michael,

    Your help definitely pointed me in the right direction. With the info you provided I was able to find more info on the spec and what browsers support the api.

    I didn't get around to checking this on mobile but I don't suspect that mobile browsers would be more consistent api or even have it implemented better than any of the above browsers. Seems fairly new and the browsers organizations are still trying to figure out and are struggling to follow the documented spec. Reminds me a bit of CSS flex-box a bit.

    Thanks guys!