Android 添加重启

1.长按powe on 键列表添加重新启动

android\frameworks\base\policy\src\com\android\internal\policy\impl\GlobalActions.java

        mItems = Lists.newArrayList(
                // silent mode
                mSilentModeToggle,
                // next: airplane mode
                mAirplaneModeOn,
                // last: power off
                new SinglePressAction(
                        com.android.internal.R.drawable.ic_lock_power_off,
                        R.string.global_action_power_off) {

                    public void onPress() {
                        // shutdown by making sure radio and power are handled accordingly.
                        ShutdownThread.shutdown(mContext, true);
 
      //LGE_DEV_PORTING UNIVA_S jonghyuck.shin@lge.com - can't create LowBattery Popup while power-off
      Intent shutdownIntent = new Intent(Intent.ACTION_START_SHUTDOWN);
      mContext.sendBroadcast(shutdownIntent);
      //LGE_DEV_PORTING UNIVA_E      

                    }

                    public boolean showDuringKeyguard() {
                        return true;
                    }

                    public boolean showBeforeProvisioning() {
                        return true;
                    }
                },
                //haifeng.gong 20120328 add Reboot[START]
                new SinglePressAction(
                        com.android.internal.R.drawable.ic_lock_restart,
                        R.string.global_action_power_restart) {

                    public void onPress() {
                        // Reboot  by making sure radio and power are handled accordingly.
                        ShutdownThread.reboot(mContext, "",true);    

                    }

                    public boolean showDuringKeyguard() {
                        return true;
                    }

                    public boolean showBeforeProvisioning() {
                        return true;
                    }
                }
               //haifeng.gong 20120328 add Reboot[END]
              );

 

 

添加values/string ---global_action_power_restart (android\frameworks\base\core\res\res\values

 <!--haifeng.gong 20120328 add Reboot[START]-->
 <string name="global_action_power_restart">Restart</string>
 <!--haifeng.gong 20120328 add Reboot[END]--> 

以及对应中文等其他语言

添加drawable ---ic_lock_restart.png(android\frameworks\base\core\res\res\drawable-mdpi

 

2.弹出对话框

 修改弹出框token(android\frameworks\base\core\java\com\android\internal\app)

  new AlertDialog.Builder(context)
   .setIcon(android.R.drawable.ic_dialog_alert)
   .setTitle(mReboot?com.android.internal.R.string.global_action_power_restart:com.android.internal.R.string.power_off)
   .setMessage(mReboot?com.android.internal.R.string.restart_confirm:com.android.internal.R.string.shutdown_confirm)
   .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() {

....}

根据mReboot显示 关机还是重启

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值