为android电源键添加重启项
2013-01-25 10:17
323 查看
先看一张图片:
那么要加重启项要怎么做呢?
首先在源码中找到按电源弹出的选项的源文件,也就是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必须在资源文件下添加,再编译资源文件。。。
在 framework/base/core/res/res/values/string.xml下添加
<string name="global_action_reboot">reboot</string>
<string name="reboot_progress">rebooting...</string>
在 framework/base/core/res/res/values-zh-rCN/string.xml下添加
<string name="global_action_reboot">重启</string>
<string name="reboot_progress">重启...</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硬件不支持重启,所以只能关机之后并不能重启)。
那么要加重启项要怎么做呢?
首先在源码中找到按电源弹出的选项的源文件,也就是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必须在资源文件下添加,再编译资源文件。。。
在 framework/base/core/res/res/values/string.xml下添加
<string name="global_action_reboot">reboot</string>
<string name="reboot_progress">rebooting...</string>
在 framework/base/core/res/res/values-zh-rCN/string.xml下添加
<string name="global_action_reboot">重启</string>
<string name="reboot_progress">重启...</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硬件不支持重启,所以只能关机之后并不能重启)。
相关文章推荐
- Android 5.1长按电源键添加重启功能
- 长按电源键,为Android手机添加自动重启Item
- Android 5.1长按电源键添加重启功能
- 长按电源键,为Android手机添加自动重启Item
- 为android电源键添加重启项
- 长按电源键,为Android手机添加自动重启Item
- 【ROM修改教程】添加高级电源重启菜单(安卓4.0.4官方ROM)
- android5.1添加android长按power键重启功能
- android 在关机界面添加重启功能
- Android 添加重启
- 【ROM修改教程】添加高级电源重启菜单(安卓4.0.4官方ROM)
- Android 关机界面添加重启菜单功能
- android5.1添加android长按power键重启功能
- android4.2添加重启菜单项
- Android 6.0开发实现关机菜单添加重启按钮的方法
- Android系统移植与调试之------->如何修改Android设备添加重启、飞行模式、静音模式等功能(二)
- Android 4.1.2系统添加重启功能
- android:configChanges中单独添加locale,切换语言后Activity重启
- android电源添加重启项
- Android 4.1.2系统添加重启功能