0

I have the following code which is supposed to be very straight forward, but does not work :

public class DisplayChapter extends ListActivity {

...

 @Override
       public boolean onOptionsItemSelected(MenuItem item) {
           switch (item.getItemId()) {
            case MENU_SEARCH:
                    onSearchRequested();
                    return true;
                case MENU_TEST:
                    WindowManager.LayoutParams lp = getWindow().getAttributes();  
                    lp.dimAmount=1.0f; 
                    getWindow().setAttributes(lp); 
                    Toast.makeText(this, "dimmed?", Toast.LENGTH_SHORT).show(); 
                    break;

When I press the MENU_TEST button, the screen does not become dimmed. Any idea why? I tested on the device running Android 4.1.2 and on emulator.

Ivan
  • 6,388
  • 3
  • 24
  • 30

1 Answers1

0

I used WindowManager.LayoutParams.screenBrightness property instead of dimAmount and it works :)

Ivan
  • 6,388
  • 3
  • 24
  • 30