分享

AIR for Android and Wake Lock with Keyguard |...

 深入敌后_ 2013-04-05

AIR for Android and Wake Lock with Keyguard

I have an application where I want to prevent sleeping, but I still want the user to be able to lock the screen using the power button.  The conventional wisdom is to do something like the following:

protected function view1_addedToStageHandler(event:Event):void

{

    NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

    stage.addEventListener(Event.DEACTIVATE, releaseWakeLock);

}

protected function releaseWakeLock(event:Event):void{

    NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL;

}

This, however, does not work.  The problem seems to be that the Android OS receives the sleep event before the AIR application does, and therefore when the user presses the power button again, the screen is not locked.  The solution, fortunately, is simple – just don’t enable the DISABLE_KEYGUARD permission in the android manifest.  The comments from Adobe say to toggle both DISABLE_KEYGUARD and WAKE_LOCK together, but everything seems to work as I would expect with just WAKE_LOCK.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多