小编GCh*_*nna的帖子

如何使用SeekBar以编程方式调整设备亮度?

我的设置应用程序中有两个搜索栏,一个用于声音,另一个用于亮度.我的声音搜索栏确实改变了我想要的媒体音量,并且它在其他活动和应用程序中保持不变,但亮度搜索栏在我更改活动后不会保持更改,它只会更改设置页面中的亮度.我希望实现的是,即使在其他活动和应用程序中,它们也可以保留在应用程序设置页面中设置的任何内容.

ApplicationSettings.java

public class ApplicationSettings extends AppCompatActivity {

private SeekBar VolumeSeekbar = null;
private SeekBar BrightnessSeekbar = null;
private AudioManager audioManager = null;
private float BackLightValue;
//Seek bar object
private SeekBar seekBar;
//Variable to store brightness value
private int brightness;
//Content resolver used as a handle to the system's settings
private ContentResolver cResolver;
//Window object, that will store a reference to the current window
private Window window;
TextView txtPerc;



@Override
public void onCreate(Bundle savedInstanceState) {
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_application_settings);

    //Instantiate seekbar …
Run Code Online (Sandbox Code Playgroud)

java android screen-brightness android-settings

1
推荐指数
1
解决办法
5776
查看次数