SLEEP SHUTDOWN REBOOT on Android

3 368
NOVA17  
Hi there,

Is anyone know how to sleep, shutdown and reboot the LeMaker Guitar using a command line on Android?

Peace,
This is a nice app, works just with a click:
https://play.google.com/store/ap ... lications.quickboot

Edited by sghazagh at Sep 28, 2016 14:57

Hi,
Depends...
If you want to develop an application yourself, you need to access the shell to issue a command.
For doing that and for doing what you are looking for, you normally need ROOT access to your device.
      
You should grab the standard input of the SU process just launched and write down the command there, otherwise you are running the commands with the current UID.
Try something like this:
  1. try{
  2.     Process su = Runtime.getRuntime().exec("su");
  3. .
  4. .
  5. .
  6.     su.waitFor();
  7. }catch(IOException e){
  8.     throw new Exception(e);
  9. }catch(InterruptedException e){
  10.     throw new Exception(e);
  11. }
Copy the Code

If you want, you can use this library available in GITHUB: "https://github.com/Chainfire/libsuperuser" to access to ROOT from your app.
That's from Chainfire and you can add it to your gradle file:

  1. dependencies {
  2.     compile 'eu.chainfire:libsuperuser:1.0.0.+'
  3. }
Copy the Code

See the samples in their GIT and see how you can access shell by this library. Then you can issue any command you would like from you app.

For example, you can use AsyncTask and do it in background:
  1. suAvailable = Shell.SU.available();
  2. if (suAvailable) {
  3. suVersion = Shell.SU.version(false);
  4. suVersionInternal = Shell.SU.version(true);
  5. suResult = Shell.SU.run(new String[] {
  6. "su -c 'svc power reboot recovery'  "              //Ex. Reboot to Recovery, Tested on Android 5.0 and 6.0.1
  7. });
Copy the Code

If not, and only need an application, then try the one 'actkk200' is recommended. There are couple of others which you can find in Google Play Store too.

Hope it helps

reboot,
stop,start,
busybox reboot -p

You have to log in before you can reply Login | Sign Up

Points Rules