Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we ON or OFF the device programatically?

Tags:

android

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?

like image 514
Pankaj Kumar Avatar asked Sep 29 '11 12:09

Pankaj Kumar


People also ask

How to Keep screen on in Android programmatically?

Using android:keepScreenOn="true" is equivalent to using FLAG_KEEP_SCREEN_ON . You can use whichever approach is best for your app. The advantage of setting the flag programmatically in your activity is that it gives you the option of programmatically clearing the flag later and thereby allowing the screen to turn off.

What is wake lock permission Android?

A wakelock is a powerful concept in Android that allows the developer to modify the default power state of their device. The danger of using a wakelock in an application is that it will reduce the battery life of a device.


2 Answers

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

like image 71
Mob Avatar answered Sep 20 '22 18:09

Mob


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

like image 20
Migol Avatar answered Sep 20 '22 18:09

Migol