Android的根关机 [英] Android root poweroff

查看:149
本文介绍了Android的根关机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的root用户的​​Andr​​oid应用程序,我执行与停机时

On my android app for root user, I perform a shutdown with

su reboot -p

它的工作不错,但我注意到,该手机处于关机几乎立即(从显示关机动画,以及可能做其他的东西不是)。

It works ok, but I noticed that the phone is shutdown almost instantly (as opposed from showing the shutdown animation, and probably doing other stuff).

这是正确的方式来关机Android手机编程?是否有一些关键的code,需要关闭之前被执行?

Is this the correct way to shutdown an android phone programmatically? Are there some critical code that requires to be executed before shutdown?

推荐答案

在源$ C ​​$ C,你可以找到以下内容:

In the source code you can find the following:

/**
 * Low-level function turn the device off immediately, without trying
 * to be clean.  Most people should use
 * {@link android.internal.app.ShutdownThread} for a clean shutdown.
 *
 * @deprecated
 * @hide
 */
@Deprecated
public static native void shutdown();

我觉得这个原生功能与你的苏重启-p 。此外,你可以从评论看,你应该使用ShutdownThread做一个干净的关闭。

I think that this native function corresponds to yours su reboot -p. Moreover, you can see from the comment that you should use ShutdownThread to make a clean shutdown.

在此线程的Andr​​oid关闭ActivityManager(我想关闭ActivityManager意味着所有活动将通过必要的生命周期,因此,活动的状态将被存储[但我不知道,我没有检查]),那么Android的转向无线接口,之后,它会关闭蓝牙,并在年底它会尝试关闭MountService。

In this thread Android shuts down ActivityManager (I think shutting down ActivityManager means that all activities will pass necessary lifecycle and, thus, the states of activities will be stored [but I'm not sure, I did not check]), then Android turns of Radio interface, after that it turns off Bluetooth, and at the end it tries to shutdown MountService.

因此​​,你可以看到,这是不正确的方式使用苏重启-p

Thus, you can see that it's not the right way to use su reboot -p.

这篇关于Android的根关机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆