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.