Dim iPhone Screen, but don't let it sleep

Viewed 6548

Update

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/index.html#//apple_ref/occ/instp/UIScreen/brightness

That's the Apple Doc for controlling screen brightness. Below is the original question.


I have found by using Google 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?

5 Answers

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?

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.

Related