6

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();  
}
Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Michael Frans
  • 613
  • 3
  • 23
  • 49
  • http://stackoverflow.com/questions/3745523/programmatically-switching-off-android-phone – Nikunj Patel Sep 29 '11 at 04:18
  • @Michael Petrotta: thank you for your information.. but i want my device is turned off not reeboot.. do you havw any idea?? – Michael Frans Sep 29 '11 at 04:32
  • Michael, I think you meant to contact @Dr.nik. – Michael Petrotta Sep 29 '11 at 04:35
  • Come on you can always do it. Just pull a branch of android , customize it according to your wish and in your `mainfest` remove the filters, permissions that don't allow you to do that. Now , you have to play with the battery if I talk of more depth. But if you just want to trigger the click on `power off` then its far simpler then. – Prateek May 23 '13 at 07:56

3 Answers3

6

It is impossible with the public Android SDK.

Michell Bak
  • 13,182
  • 11
  • 64
  • 121
  • I'm agree w u. If we have permission to automatically turn off device, malware app can spread all over Market :( – anticafe Oct 03 '11 at 11:22
  • 1
    Use a vuln to inject something nasty into the boot sequence, then turn off the device, so that when the device is restarted by the user, the payload is delivered? – mikołak May 23 '13 at 08:01
1

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.

DynamicMind
  • 4,240
  • 1
  • 26
  • 43
0

This is what can provide you an insight of the OS you are working on , and not about developing an app that would run on any device, as you have not made OS's for them.

Just pull a branch of android , customize it according to your wish and in your mainfest remove the filters, permissions that don't allow you to do that, or add your owns. Now , you have to play with the battery if I talk of more depth.

But if you just want to trigger the click on power off then its far simpler then.

Prateek
  • 3,923
  • 6
  • 41
  • 79