I assume you need to jailbreak to get access to system controls like this, but I'll throw this out there in case someone has discovered a handy solution...
Yes, Apple will reject your app if you mess with the brightness. Although, if you still want to do it, you'd get the current brightness like this:
Code:
-(void)getBacklightLevel;{
NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel" ), CFSTR("com.apple.springboard"));
previousBacklightLevel = [bl floatValue]; //a variable to store the previous level so you can reset it.
[bl release];
}
And to set the backlight level, add this line
Code:
GSEventSetBacklightLevel(newLevel); //The new level: 0.0 - 1.0.
In order for this to work, you will need to include GraphicsServices.h. Depending on where you get your headers, you may need to add the GSEventSetBacklightLevel(float value); method to the headers, else the method won't quite work. [Some have reported kernel panics by not amending the header, but that has not been my experience]
Yes, Apple will reject your app if you mess with the brightness. Although, if you still want to do it, you'd get the current brightness like this:
Code:
-(void)getBacklightLevel;{
NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel" ), CFSTR("com.apple.springboard"));
previousBacklightLevel = [bl floatValue]; //a variable to store the previous level so you can reset it.
[bl release];
}
And to set the backlight level, add this line
Code:
GSEventSetBacklightLevel(newLevel); //The new level: 0.0 - 1.0.
In order for this to work, you will need to include GraphicsServices.h. Depending on where you get your headers, you may need to add the GSEventSetBacklightLevel(float value); method to the headers, else the method won't quite work. [Some have reported kernel panics by not amending the header, but that has not been my experience]
wow sorry to raise such as an old thread, but does anyone know if this still works. I can't seem to return the current backlight value anymore (I'm sure it worked once)....its for a private app BTW so no App store violations
I believe the application 'Light' was removed from the store for messing with the screen brightness.
I've seen two applications ("Astronomy Flashlight" and "Flashlight.") in the store that adjust the screen's brightness one way or another. They probably don't adjust the system brightness but they seem to have a way to "dim" the screen. Any ideas? It appears possible if (at least) two apps have made it into the store.
In order for this to work, you will need to include GraphicsServices.h. Depending on where you get your headers, you may need to add the GSEventSetBacklightLevel(float value); method to the headers, else the method won't quite work. [Some have reported kernel panics by not amending the header, but that has not been my experience]
I think Flashlight may just be using different color backgrounds... gray's appear dimmer than whites.
Perhaps, but that doesn't explain how "Astronomy Flashlight" works and even if "Flashlight." does just use grays, how does it fade from one color to the gray?
Perhaps, but that doesn't explain how "Astronomy Flashlight" works and even if "Flashlight." does just use grays, how does it fade from one color to the gray?
they don't adjust the backlight levels...all they are doing is adjusting the alpha level of the top (red) view.
they don't adjust the backlight levels...all they are doing is adjusting the alpha level of the top (red) view.
Oh, I see. Thanks.
So does anyone know how to find the GraphicsServices library? I know I won't be able to submit it to the App Store, but I can still use it personally, can't I? I located the GraphicsServices.framework (several, actually), but when I try and expand it there are no headers listed? Did Apple just remove access to this completely or is there something else that needs to be done? TIA.
So does anyone know how to find the GraphicsServices library? I know I won't be able to submit it to the App Store, but I can still use it personally, can't I? I located the GraphicsServices.framework (several, actually), but when I try and expand it there are no headers listed? Did Apple just remove access to this completely or is there something else that needs to be done? TIA.
GSEventSetBacklightLevel works fine on 4.2. Didn't try getting the level.
There is another problem, though. Once I lock the phone and press the home button to use it again, the brightness is back to it's state before I changed it in my app.
I'm also trying to get this working, but i have no success at all
all i get is this error:
Code:
"_GSEventSetBacklightLevel", referenced from:
-[MainViewController setBacklightLevel:] in MainViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
GSEventSetBacklightLevel works fine on 4.2. Didn't try getting the level.
There is another problem, though. Once I lock the phone and press the home button to use it again, the brightness is back to it's state before I changed it in my app.
Any way to save the changes so they'll last?
Thanx,
Nir.
Hi,I want to use GSEventSetBacklightLevel, and I have #import "GraphicsServices.h", but there is a error. "_GSEventSetBacklightLevel", referenced from: .... symsbol not found.
And I can't find GraphicsServices.framework.How can I do to use GSEventSetBacklightLevel ?
Hi,I want to use GSEventSetBacklightLevel, and I have #import "GraphicsServices.h", but there is a error. "_GSEventSetBacklightLevel", referenced from: .... symsbol not found.
And I can't find GraphicsServices.framework.How can I do to use GSEventSetBacklightLevel ?
Hi,
i Managed to get it working, maybe you/someday some else can find your/his solution with my code snip.
I used to change the backlight level with a UISlider, and programmatically with some "pulse" effect.
some vars needed in my code
Code:
// init global vars
_currentBacklightLevel = 0.2f;
[self setBacklightLevel:_currentBacklightLevel];
_pulseBacklightDirection = 0; // 0 = off, 1 = up, 2 = down
they don't adjust the backlight levels...all they are doing is adjusting the alpha level of the top (red) view.
Hey I wanted to know. Since we're not allowed to tamper with the backlight, does dimming the screen by putting a black background and lowering the alpha of everything in front of it offer any energy savings? Anything close to lowering the backlight or not worth it? Does it actually cost more?
where can i to get "GraphicsServices.h." this file ? thanks
where can i to get "GraphicsServices.h." this file ? thanks
Quote:
Originally Posted by SkylarEC
Yes, Apple will reject your app if you mess with the brightness. Although, if you still want to do it, you'd get the current brightness like this:
Code:
-(void)getBacklightLevel;{
NSNumber *bl = (NSNumber*) CFPreferencesCopyAppValue(CFSTR("SBBacklightLevel" ), CFSTR("com.apple.springboard"));
previousBacklightLevel = [bl floatValue]; //a variable to store the previous level so you can reset it.
[bl release];
}
And to set the backlight level, add this line
Code:
GSEventSetBacklightLevel(newLevel); //The new level: 0.0 - 1.0.
In order for this to work, you will need to include GraphicsServices.h. Depending on where you get your headers, you may need to add the GSEventSetBacklightLevel(float value); method to the headers, else the method won't quite work. [Some have reported kernel panics by not amending the header, but that has not been my experience]