Can we switch off an Android phone programmatically?
I am using following snippet but it didn\'t work for me.
KeyguardManager keyguardManager = (Keyg
Actually, the above responses are not completely accurate, in my experience. I was experimenting with ways to dim the screen and found that the following:
Window w = getWindow();
WindowManager.LayoutParams lp = w.getAttributes();
lp.screenBrightness =.005f;
w.setAttributes (lp);
will actually turn my Samsung Galaxy Tab off if, instead of 0.005, I use a screen brightness value of 0.
I suspect this is bug somewhere, but I don't have sufficient hardware to test the code on other Android models. Hence, I can't really tell you what will happen on your phone. I can tell you that my code shuts of my phone even completely unsigned.