Android exit, no lock screen

Source: Internet
Author: User

Cocos2dxglsurfaceview.javapublic boolean onKeyDown (final int pkeycode, final keyevent pkeyevent) {switch (Pkeycode) { Case KeyEvent.KEYCODE_BACK:Cocos2dxActivity.clossGame (); return true;case KeyEvent.KEYCODE_MENU:this.queueEvent ( New Runnable () {@Overridepublic void run () {Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleKeyDown (Pkeycode);}}); Return True;default:return Super.onkeydown (Pkeycode, pkeyevent);}} Cocos2dxactivity.javaimport Android.app.alertdialog;import Android.content.dialoginterface;import Android.app.dialog;public static void Clossgame () {log.info ("return!"); Cocos2dxactivity mainactivity = (cocos2dxactivity) scontext;mainactivity.onpause ();D ialog alertDialog = new                 Alertdialog.builder (mainactivity).                 Settitle ("Game Tips"). Setmessage ("Are you sure you want to exit the game?"                ").                     Setpositivebutton ("OK", new Dialoginterface.onclicklistener () {@Override public void OnClick (Dialoginterface dialog, int which) {//TODO auto-generated method stub cocos2dxactivity mainactivity = (cocos2dxact                ivity) Scontext;                                Mainactivity.finish ();                    System.exit (0);                }                 }).                     Setnegativebutton ("Cancel", new Dialoginterface.onclicklistener () {@Override  public void OnClick (Dialoginterface dialog, int which) {//TODO auto-generated method                Stub cocos2dxactivity mainactivity = (cocos2dxactivity) scontext;                    Mainactivity.onresume ();                }                 }).         Create (); Alertdialog.show (); }



Import Android.view.WindowManager; GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);   Keep the screen highlighted while the app is running, without locking the screen



Android exit, no lock screen

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.