Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Could someone explain to me a use case for the battery API? I can't think of a single situation where it would be beneficial. The article states that you can detect if a user's battery is low to avoid battery-intensive processes, but do you think developers are going to spend their time inflating their scripts to deliver a poorer web experience to their users just because they have a low battery?


Remember that Mozilla is making a mobile OS based on Firefox, where all apps are written in HTML/JS.

As part of this, they're adding API's to provide the sort of hooks that mobile apps need, such as being aware of battery status.

They would also like these to be standardized across all browsers, so that HTML apps can properly compete with "native" apps.


Most developers probably aren't going to use ANY new HTML5 features in the near future. That hardly means they have no value.

A perfectly reasonable example is a Twitter client that switches from auto-refreshing to manual refresh when the battery is low.


Video games, more specifically, 3D video games.

You could query the API, if they've got <50% battery left, adjust the draw distance to decrease rendering for longer play.

It's very niche, but along with video games, i'm sure some novel hacker will find a use for it!


Save prompts when the battery is low?


Quick poll: Which is worse...

a) Battery-aware HTML5 apps

b) Having a save command


Ok, what about more frequent autosaves?


Android's APIs enable easy implementation of a sqlite-based data model, where changes are always persisted.

That doesn't solve the problem for things like CAD that need an in-memory object-oriented data model, but the Android support for observer patterns can be wrapped around any data model, and the ability to quickly, which means, in practice, incrementally, persist changes is driven by both Android-specific issues like needing to respond to lifecycle events quickly, and by general mobile considerations like a battery that could fail unexpectedly.

In other words, you need to solve the "don't explicitly save" problem for reasons ranging from "it's more robust" to "it fits Android UI conventions" anyway.


Wouldn't those drain the battery?


I think its a step in the correct version if HTML5 is every able to compete with native apps on mobile. HTML5 needs better access to hardware elements. We can see two out of these five here - the camera and battery level.


The one way in which web apps still cannot compete effectively on mobile and which gets no attention is access to a user's contacts/address book.

Right now on the web Facebook and convoluted non-standard APIs to your email provider are pretty the only way to get access to contacts. This is the number one barrier to allowing web apps to spread easily when a user wants to share the app or something in the app with a friend.


HTML 5 games can show battery status, or warn when the battery is running low. HTML 5 apps can suggest that the user save their work as they are running low on power, to name a few.


It makes sense in combination with the fullscreen API for example, which hides the native indicator.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: