Android shutdown interface adds the restart menu Function

Source: Internet
Author: User

 

 

Long press the power key and add the restart menu in the pop-up Global actions dialog box, as shown below:

If you need to add the restart menu to restart your phone, follow these steps:

1,Add tags in alpsrameworksasecore es esaluesstrings. xml:

Reboot

The string resource used to display the restart menu item. If you need to add an identifier for another language, add the corresponding resource under res folder of another replaceable resource.

Note: to ensure that the resource file can be compiled, add the resource to symbols. xml synchronously.

 

2,Add the icon to alpsrameworksasecore es esdrawable-hdpi:

Zzzzz_ic_lock_power_reboot.png

 

3,In alpsrameworksasepolicysrccomandroidinternalpolicyimplGlobalActions. java

Add the following to the createDialog () function in the file:

Private GlobalActionsDialog createDialog (){

......

MItems = new ArrayList ();

// First: power off

MItems. add (......);

//////////////////////////////////////// //// Added for reboot items start

MItems. add (

New SinglePressAction (

Com. android. internal. R. zzzzz_ic_lock_power_reboot,

R. string. zzzzz_global_action_power_reboot ){

Public void onPress (){

MWindowManagerFuncs. reboot (true );

}

Public boolean onLongPress (){

MWindowManagerFuncs. rebootSafeMode (true );

Return true;

}

Public boolean showDuringKeyguard (){

Return true;

}

Public boolean showBeforeProvisioning (){

Return true;

}

});

/// // Added end

// Next: airplane mode

MItems. add (mAirplaneModeOn );

......

}

 

4,In the frameworksasecorejavaandroidiewWindowManagerPolicy. java file, find the interface Definition of WindowManagerFuncs and add the following function declaration:

Public interface WindowManagerFuncs {

Public void reboot (boolean confirm );

}

 

5,In FrameworksaseservicesjavacomandroidserverwmWindowManagerService. java, because it implements the WindowManagerFuncs interface, you need to add the reboot () function implementation body to the file.

Find the shutdown () function and add the reboot () function after it. The function content is as follows:

// Called by window manager policy. Not exposed externally.

@ Override

Public void reboot (boolean confirm ){

ShutdownThread. reboot (mContext, confirm );

}


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.