android - 按下电源按钮超过 10 秒时设备不重启
问题描述
我正在具有 android 源代码的设备上进行编码。在普通的安卓设备上,当我长按电源按钮 10 秒时,设备会重新启动,但在我的情况下,当我长按电源按钮 10 秒时,设备会关闭。你有一个想法,在android源代码中,这个功能是编码的(这样我就会明白我的问题在哪里)?
解决方案
干得好:
private final Runnable mPowerLongPress = new Runnable() {
public void run() {
// The context isn't read
if (mLongPressOnPowerBehavior < 0) {
mLongPressOnPowerBehavior = mContext.getResources().getInteger(
com.android.internal.R.integer.config_longPressOnPowerBehavior);
}
switch (mLongPressOnPowerBehavior) {
case LONG_PRESS_POWER_NOTHING:
break;
case LONG_PRESS_POWER_GLOBAL_ACTIONS:
mPowerKeyHandled = true;
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
showGlobalActionsDialog();
break;
case LONG_PRESS_POWER_SHUT_OFF:
mPowerKeyHandled = true;
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
ShutdownThread.shutdown(mContext, true);
break;
}
}
};
推荐阅读
- javascript - React 类组件方法:我的代码是必须的吗?
- javascript - 在(Vue,React)中导出带有子模块的模块的最佳方法是什么
- python - 计算不同颜色的像素 - Python
- python - 使用 intellj 在 python 窗口 10 中导入 mxnet
- c# - 从 html 帮助程序中获取未编码的 html
- java - 具有多个可调用对象的空指针异常
- php - 根据mysql表创建列表形式
- c# - 使用 C# 的 UPDATE 语句中的语法错误
- haskell - Haskell 中的实例展示树
- c++ - 将编译器标志添加到 CMakeLists.txt