gpt4 book ai didi

android - 如何知道设备已关机

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:45:01 26 4
gpt4 key购买 nike

我想在移动设备关闭时做一些事情,但我不知道方法是什么;你能告诉我如何检测移动设备是否正在关闭吗?
我知道手机重启android.intent.action.BOOT_COMPLETED的方法,但是找不到类似的关机方法。

最佳答案

http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN

public static final String ACTION_SHUTDOWN

Since: API Level 4 Broadcast Action: Device is shutting down. This is broadcast when the device is being shut down (completely turned off, not sleeping). Once the broadcast is complete, the final shutdown will proceed and all unsaved data lost. Apps will not normally need to handle this, since the foreground activity will be paused as well. This is a protected intent that can only be sent by the system.

Constant Value: "android.intent.action.ACTION_SHUTDOWN"

这似乎是它?我刚刚用谷歌搜索了你的命令,它在标准广播操作列表中。 :)

关于android - 如何知道设备已关机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5076410/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com