views:

424

answers:

2

Happy Holidays!

Alright, so here is my question. I have found by using Google (Hurray, GIYF) that I can disable the iPhone going to sleep in an application by using:

application.idleTimerDisabled = YES;

so the code looks like this:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after application launch

    // This disables the autosleep  I added this to TEST, 
    // delete later if you want:-
    application.idleTimerDisabled = YES;
    [window addSubview:switchViewController.view];
    [window makeKeyAndVisible];

Perfect, it works well. However, my question is, can I somehow disable the iPhone from going to sleep, while still allowing the screen to dim? Or perhaps dim the screen myself in the app as to save battery power?

I definitely don't want the iPhone sleeping, but I'd also like to be user friendly/battery friendly and dim the screen. (You know, like how you can set the iPhone to dim the screen X seconds before it goes to sleep.) Is there an effective way to do this? Thanks!

A: 

Can you set proximityState to trick the iPhone into thinking that it is close to someone's ear? This would work with the iPhone, but not the iPod touch. There is no way to selectively turn adjust the brightness ... apps that dim the screen typically do so by putting a partly transparent image over the current one.

Andrew
+2  A: 

I'm pretty sure there's nothing in the official SDK.

[(id)[UIApplication sharedApplication] setBacklightLevel:0.3f]; // or whatever value

works, but is of course undocumented. The recent experience with UIGetScreenImage indicates that perhaps the right strategy with useful but undocumented APIs is to use them and see what happens.

Failing that, has anybody ever measured if the phone's power consumption goes down if it's showing a black image, or does it not help unless you can turn down the backlight?

David Maymudes
Cool, thanks for your insight. I'll play around and see if I can get anything done.
Wayfarer