Note that there are some explanatory texts on larger screens.

plurals
  1. POBrightness Control Not Reflecting on the Device
    primarykey
    data
    text
    <p>I am trying to imitate the Andorid setting widget that can control the brightness of the device. It works as intended and I can see that see in the settings. But I don't see the device brighten.</p> <p>Here is the code:</p> <pre><code>WindowManager.LayoutParams lp = getWindow().getAttributes(); SeekBar brightnessControl = (SeekBar) findViewById(R.id.sbBrightness); int currentBrightness = 10; brightnessControl.setProgress(currentBrightness); lp.screenBrightness = currentBrightness/100f; brightnessControl.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) {} @Override public void onStartTrackingTouch(SeekBar seekBar) {} @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { //set local brightness WindowManager.LayoutParams lp = getWindow().getAttributes(); progress = (progress &lt;= 10)?10:progress; lp.screenBrightness = progress/100f; getWindow().setAttributes(lp); //put local to system wide brightness int sysWideBrightness = (int) (progress/100f * 255); android.provider.Settings.System.putInt( getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, sysWideBrightness); } }); </code></pre> <p>I would mention that this activity is fired on an Activity tab. Before putting it in a tab it works fine, but not it doesn't. </p> <p>I notice that when I put a new version of android on my device (now 4.2.2 rooted) it was able to work as intended. I tested it on a rooted gingerbread device it doesn't work. </p> <p>This might help, this is the Main.java file and here is how the ActivityTab is initiated.</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* TabHost will have Tabs */ tabHost = (TabHost)findViewById(android.R.id.tabhost); TabSpec firstTabSpec = tabHost.newTabSpec("tid1"); TabSpec secondTabSpec = tabHost.newTabSpec("tid2"); TabSpec thirdTabSpec = tabHost.newTabSpec("tid3"); TabSpec fourthTabSpec = tabHost.newTabSpec("tid4"); TabSpec fifthTabSpec = tabHost.newTabSpec("tid5"); firstTabSpec.setIndicator("", getResources().getDrawable(R.drawable.clear_cache_tab)).setContent(showClearCache()); secondTabSpec.setIndicator("", getResources().getDrawable(R.drawable.move_sd_tab)).setContent(showMoveToSd()); thirdTabSpec.setIndicator("", getResources().getDrawable(R.drawable.remove_app_tab)).setContent(showRemoveApp()); fourthTabSpec.setIndicator("", getResources().getDrawable(R.drawable.feature_manager_tab)).setContent(showFeatureManager()); fifthTabSpec.setIndicator("", getResources().getDrawable(R.drawable.feature_manager_tab)).setContent(showProcessKill()); tabHost.setOnTabChangedListener(this); tabHost.addTab(firstTabSpec); tabHost.addTab(secondTabSpec); tabHost.addTab(thirdTabSpec); tabHost.addTab(fourthTabSpec); tabHost.addTab(fifthTabSpec); for(int i=0;i&lt;tabHost.getTabWidget().getChildCount();i++) { tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#303030")); } tabHost.getTabWidget().setCurrentTab(0); tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#C8C8C8")); } @Override public void onTabChanged(String tabId) { // TODO Auto-generated method stub for(int i=0;i&lt;tabHost.getTabWidget().getChildCount();i++) { tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#303030")); } tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#C8C8C8")); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload