如何在android中以編程方式關閉,我搜索了這個問題,並且我發現很多回答最強的答案都表示你的手機必須是ROOT,現在我的手機是root並且我的代碼工作正常 但是當我在下面執行此代碼時,得到如下圖所示的警報。如何以編程方式關閉android手機?
代碼:
try {
Process proc = Runtime.getRuntime()
.exec(new String[]{ "su", "-c", "reboot" });
proc.waitFor();
} catch (Exception ex) {
ex.printStackTrace();
}
我的結果:
現在如何,當我按我的關機程序按鈕,沒有得到這消除這種警告我想直接關閉警惕。 感謝您的任何幫助。
關機是一個根命令..爲此您的應用程序需要root權限。那麼爲什麼不給它根權限? – Gudgip
好的如何給它? – ROR
本主題將幫助您:http://stackoverflow.com/questions/16217294/how-to-grant-root-access-to-a-specific-application-from-source-code-instead-of-r – Gudgip