Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am new to android. Today i create a small android app, in which i have to change the screen brightness of the device.
i am using the following code (got from goggling). and also add permission in manifest file. when executing this code,brightness level in the notification area becomes full.but screen brightness have no changes. how can i fix it? please help me.

code in activity.java

Java
if(iBlank == 0){ 	
               	
               	try {
			curBrightnessValue=android.provider.Settings.System.getInt(getContentResolver(),  android.provider.Settings.System.SCREEN_BRIGHTNESS);
			android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS,255);
				} 
catch (SettingNotFoundException e) {
				
				}
               }
               else {               	 
               	android.provider.Settings.System.putInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS,(int)curBrightnessValue);
               }


Permission in manifest file:

XML
<uses-sdk
       android:minSdkVersion="8"
       android:targetSdkVersion="14" />

   <uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900