Android 系统设置的权限(背光设置)
2010-03-25 21:21:00 来源:WEB开发网在ANDROID中,系统设置的权限一大堆,让我一直很头痛,今天我以背光调节为例子,来讲解一下相关权限,要调节背光设置,先把设置前光的JAVA源码写上:
初始化:
public void InitBrightness()
{
//相关控件,用SEEKBAR来调节背光
mChangeBtName = (TextView)this.findViewById(R.id.play_bt_change_name);
mChangeBar = (SeekBar)this.findViewById(R.id.bt_set_seekbar);
//mChangeBar.setOnFocusChangeListener(this);
//获取当前背光亮度并在SEEKBAR上呈现
try {
mOldBrightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
} catch (SettingNotFoundException snfe) {
mOldBrightness = MAXIMUM_BACKLIGHT;
}
Log.v("Brightness", "number" + mOldBrightness);
mChangeBar.setMax(MAXIMUM_BACKLIGHT - MINIMUM_BACKLIGHT);
Log.v("Brightness max", "setmax:" + (MAXIMUM_BACKLIGHT - MINIMUM_BACKLIGHT));
mChangeBar.setProgress(mOldBrightness - MINIMUM_BACKLIGHT);
mChangeBtName.setText(String.valueOf((mOldBrightness - MINIMUM_BACKLIGHT)/25));
//进度条控制
mChangeBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStartTrackingTouch(SeekBar bar) {
}
public void onProgressChanged(SeekBar bar, int progress,boolean fromtouch) {
Log.v("Progress", "num:" + progress);
int step = 25;
Settings.System.putInt(getContentResolver(),Settings.System.SCREEN_BRIGHTNESS, progress + MINIMUM_BACKLIGHT);
Log.v("Progress", "putINTOK");
setBrightness(progress + MINIMUM_BACKLIGHT);
mChangeBtName.setText(String.valueOf(progress/step));
}
public void onStopTrackingTouch(SeekBar bar) {
}
});
}
设置背光函数:
private void setBrightness(int brightness) {
- ››Android 当修改一些代码时,使用什么编译命令可以最...
- ››Android 如何添加一个apk使模拟器和真机都编译进去...
- ››Android 修改Camera拍照的默认保存路径
- ››Android 如何修改默认输入法
- ››android开发中finish()和System.exit(0)的区别
- ››Android手势识别简单封装类
- ››android中查看项目数字证书的两种方法
- ››Android中获取IMEI码的办法
- ››android 相机报错 setParameters failed
- ››Android重启运用程序的代码
- ››Android为ListView的Item设置不同的布局
- ››android bitmap与base64字符串的互相转换
更多精彩
赞助商链接