How to power off an Android device programmatically -


how can power off android device programmatically?

i searched answer, said phone must rooted (i don't want that), , others said it's impossible.

is impossible?

you can't unless have rooted phone. easy calling shutdown command linux:

void shutdown() {      try {           process m_process=runtime.getruntime().exec("su");           dataoutputstream os = new dataoutputstream(m_process.getoutputstream());           os.writebytes("shutdown\n");           os.flush();           m_process.waitfor();      } catch (exception e) {         // todo auto-generated catch block         e.printstacktrace();     } } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -