android添加重启项(关机框中增加重启项)

本文详细介绍了如何在Android设备的关机菜单中添加自定义的重启选项,包括修改源代码、资源文件、以及编译流程等步骤,并提供了关键代码片段和必要的配置说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


首先找到按电源弹出的选项的源文件,也就是freamwork/base/policy/src/com/android/internal/policy/impl/GlobalActions.java

再找到private AlertDialog createDialog() 方法,里面有一个mItems的添加选项,在里面加入

//add by xxnan 2012-9-13
new SinglePressAction(
com.android.internal.R.drawable.ic_lock_power_off,
R.string.global_action_reboot) {

public void onPress() {
// reboot
ShutdownThread.reboot(mContext,null,false);
}

public boolean showDuringKeyguard() {
return true; freamwork/base/policy/src/com
}

public boolean showBeforeProvisioning() {
return true;
}
//add by xxnan 2012-9-13

代码即可,添加重启选项,但是R.string.global_action_reboot必须在资源文件下添加,再编译资源文件。。。

在 base/core/res/res/values/string.xml和base/core/res/res/values-zh-rCN/string.xml下添加

<string name="global_action_reboot">reboot</string>
<string name="reboot_progress">rebooting...</string>
然后找到freamwork/base/policy/src/com/android/internal/app/Shutdown.java的private static void beginShutdownSequence(Context context)
方法,将pd.setTitle(context.getText(com.android.internal.R.string.power_off));
pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));

改为if(mReboot){ // reboot progress
pd.setTitle(context.getText(com.android.internal.R.string.global_action_reboot));
pd.setMessage(context.getText(com.android.internal.R.string.reboot_progress));
}
else
{
pd.setTitle(context.getText(com.android.internal.R.string.power_off));
pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress));
}

然后就是编译了,先编译源码下的framework/base/core/res

再编译base,最后编译policy(按顺序,不然会报错)

最后将编译好的out下的system/framework/framework.jar和framework-res.apk和android.policy.jar替换你机器里system/framework的三个文件,重启,ok完成了,感兴趣的人

赶紧试一下吧。。。。(好像android硬件不支持重启,所以只能关机之后并不能重启)。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值