WEB开发网
开发学院手机开发Android 开发 Android 系统设置的权限(背光设置) 阅读

Android 系统设置的权限(背光设置)

 2010-03-25 21:21:00 来源:WEB开发网   
核心提示:在ANDROID中,系统设置的权限一大堆,Android 系统设置的权限(背光设置),让我一直很头痛,今天我以背光调节为例子,来讲解一下相关权限,要调节背光设置

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) {

1 2  下一页

Tags:Android 设置

编辑录入:coldstar [复制链接] [打 印]
赞助商链接