Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

futuremacdev

macrumors newbie
Original poster
May 1, 2008
5
0
Hi guys,
I'm just starting out with the iPhone development, so maybe I'm asking something simple. I need to programmatically retrieve some system info, such as the battery charge percentage, whether the battery is currently charging, the CPU frequency and other system info. Do you know how to do it?

I've searched the docs, but there's not a single reference to something with "battery" in the name. There are a few C functions for the Mac OSX, and even a complete BatteryInfo sample project, but nothing for the iPhone. Is that possible?

How was the BatteryInfo and HWInfo apps written for the unlocked iPhones, if there is no documented functions for this?

Any help is highly appreciated!
 

himansk

macrumors regular
Oct 16, 2006
221
0
The unlocked phones use a completely different API, I dont think the official API has exposed the hardware information to the developers otherwise I would expect somebody to have already answered your question.
 

futuremacdev

macrumors newbie
Original poster
May 1, 2008
5
0
yeah, I guess you're right...but let's admit it, it sucks! I mean, knowing the battery status is a pretty important need for many mobile apps, how could they avoid adding an API for it???

Say for example I'm using the Localization API. If the battery is full, I can update the position every 10 seconds...if it's low, I may decide to update the position every 60 seconds. But if I don't have the battery info...:(

The SDK as it is doesn't impress me much..let's just hope they'll fill the blanks..
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
yeah, I guess you're right...but let's admit it, it sucks! I mean, knowing the battery status is a pretty important need for many mobile apps, how could they avoid adding an API for it???

Say for example I'm using the Localization API. If the battery is full, I can update the position every 10 seconds...if it's low, I may decide to update the position every 60 seconds. But if I don't have the battery info...:(

The SDK as it is doesn't impress me much..let's just hope they'll fill the blanks..

If the battery is full, update the position every 60 seconds - so that the battery doesn't go low that quickly. Maybe Apple missed making the functionality available, maybe it's hidden somewhere, but maybe they just don't want you to rely on that knowledge so that you _always_ try to safe energy.
 

futuremacdev

macrumors newbie
Original poster
May 1, 2008
5
0
That's just an example of many.
Anyway, Apple should care less about what I do...if my app performs bad or drains the battery, I won't have any success and people will just uninstall it...but that's my business, not Apple's...
They should just give devs more freedom if they want the iPhone be a read application platform :rolleyes:
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Polling is a bad idea no matter what platform you do it on. Unless you are trying to turn the iPhone into a GPS navigator thing like TomTom you don't need to constantly poll.

Apple's location app updates when the user tells it to; radios are battery draining hogs so their use is supposed to be only when absolutely needed.
 

himansk

macrumors regular
Oct 16, 2006
221
0
That's just an example of many.
Anyway, Apple should care less about what I do...if my app performs bad or drains the battery, I won't have any success and people will just uninstall it...but that's my business, not Apple's...

If a phone suddenly starts draining the battery very quickly, most often the user will blame apple for it. so they are concerned of this and will try to get the developers to write better code and better apps, coz it all reflects on apple in the end.
 

futuremacdev

macrumors newbie
Original poster
May 1, 2008
5
0
Well, Win Mobile and Symbian does not have such limitations, and AFAIK users don't blame MS or Nokia for specific crap utilities, they blame the utilities' makers. Anyway, I don't see a single reason why Apple shouldn't give me battery and hardware info...it's my business to use such info the correct way. If they keep all these limits, no wonders that many devs will just produce software for the unofficial unlocked OS...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.