try as
android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS,
BRIGHTNESS_Value);
and add permission in Manifest.xml
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
</manifest>
Edit:
try as:
public class ExampleService extends Service {
@Override
public void onCreate() {
// The service is being created
// set SCREEN_BRIGHTNESS
android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.SCREEN_BRIGHTNESS,
BRIGHTNESS_Value);
/// start new Activity
Intent intent = new Intent(getBaseContext(), ExampleActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(intent);
}
@Override
public IBinder onBind(Intent intent) {
// A client is binding to the service with bindService()
return mBinder;
}
}
public class ExampleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The activity is being created.
}
@Override
protected void onResume() {
super.onResume();
// The activity has become visible (it is now "resumed").
this.finish();
}
}