6

I know there is a way where we can reboot the device. And it shows immediate result.

But my need is as :-

I want that when I will be in my class-room my phone automatically goes to OFF. (Lets say at 2:00 PM), and when I will end my class, my phone will automatically ON (Lets say at 5:00 PM).

So I am looking for the ways where I can ON/OFF the device automatically.

Is this possible? If yes how can I do it?

Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186
  • http://stackoverflow.com/questions/3745523/programmatically-switching-off-android-phone check this... – Lalit Poptani Sep 29 '11 at 12:10
  • "I know there is a way where we can reboot the device. And it shows immediate result." -- you cannot hold the permission necessary to do this, as indicated by the link in the previous comment. – CommonsWare Sep 29 '11 at 13:57

3 Answers3

3

No. Once ot goes off it cannot be turned on. I think you need to totally mute your phone rather than turning it off.

Migol
  • 8,161
  • 8
  • 47
  • 69
3

No. Third party applications do not have the permission to do that.

Check out these links

http://developer.android.com/reference/android/os/PowerManager.html http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN

Mob
  • 10,958
  • 6
  • 41
  • 58
2

If you don't want your phone to receive calls and connect to any networks, enabling/disabling the AirplaneMode by using a AlarmManager (or a Timer) might be a better idea.

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
  • Nice! If I won't get answer of my need, This must be my fav option. – Pankaj Kumar Sep 29 '11 at 12:49
  • 1
    I wouldn't use a `Timer` here, but rather `AlarmManager`. `Timer` would require a service to be in memory 24x7, which is unlikely to occur. That being said, airplane mode or muting the phone are possible, while shutting it down is not possible. – CommonsWare Sep 29 '11 at 13:56
  • That was what i was originally searching for... THX. – Lukas Knuth Sep 29 '11 at 14:49