Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off Android phone programmatically?

I want to make a lock screen application. When the phone is in the lock mode, it will turn off the phone while the USB is plugged for prevent other users from accessing the phone data. Does anyone know how to turn off Android devices programmatically so other people can't access the data while a device on the lock mode?

here's the code to lock the home button on the lock screen activity:

@Override
public void onAttachedToWindow()
{   
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
    super.onAttachedToWindow();  
}
like image 674
Michael Frans Avatar asked Sep 29 '11 02:09

Michael Frans


2 Answers

It is impossible with the public Android SDK.

like image 68
Michell Bak Avatar answered Sep 27 '22 20:09

Michell Bak


Yes it is possible,

Using making system application(Using firmware) not download application. You can get the code for power off android device from AOSP.

like image 42
DynamicMind Avatar answered Sep 27 '22 20:09

DynamicMind