tags:

views:

62

answers:

1

hello, is there a methods to keep mobile phone off using code, i have no idea about this,and hope someone give me some advice,or example , code,api

thank you

A: 

You can detect shutdown is occurring by using an Intent Receiver for the ACTION_SHUTDOWN intent. This is intended to make sure applications save any required information to disk that is specific to shutting down to prevent loss of user information.

See how to use Intents here.

See how to use the ACTION_SHUTDOWN intent here.

As for stopping shutdown, I'm pretty sure it's not possible on Android.

HXCaine
As a developer normally you don't have to care about the action_shutdown intent if you use the onPause method correct
Janusz
thank you ,i used thistry{ Process process = Runtime.getRuntime().exec("su"); DataOutputStream out = new DataOutputStream(process.getOutputStream()); out.writeBytes("reboot -p\n"); out.writeBytes("exit\n"); out.flush(); //process2.waitFor(); }catch (IOException e) { e.printStackTrace(); }also i want to know reflection ,whether is a correct matheds
pengwang
I'm afraid I don't understand what you are trying to say here
HXCaine
What he wants is to have his app shutdown the phone, not listen for when it's shutting down...
Ricardo Villamil
Ah yes, now the code makes sense. Very bad indeed
HXCaine