简体   繁体   English

Adobe Air激活/停用事件不起作用

[英]Adobe Air Activate/Deactivate events doesn't work

I can't get work Activate and Deactivate events for my Android Application. 我无法获得Android应用程序的激活和停用事件。 When I am running it on Windows it is working. 当我在Windows上运行它时,它正在工作。

In constructor of the document class I tried this: 在文档类的构造函数中,我尝试了以下操作:

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE , onActivate, false, 0, true);  
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE , onDeactivate, false, 0, true);

and

this.addEventListener(Event.ACTIVATE , onActivate, false, 0, true);
this.addEventListener(Event.DEACTIVATE , onDeactivate, false, 0, true);

and

 this.stage.addEventListener(Event.ACTIVATE , onActivate, false, 0, true);
    this.stage.addEventListener(Event.DEACTIVATE , onDeactivate, false, 0, true);

this are the functions: 这些是功能:

private function onActivate(e:Event) : void {
    new BubbleSnd().play();
}

private function onDeactivate(e:Event) : void {
    new AlertSnd().play();
}

Why I can't hear the sounds on my phone? 为什么我听不到手机上的声音? When I press on home button, I deactivate focus so I should hear the sound...but nothing happends. 当我按下主屏幕按钮时,我会取消对焦,因此我应该听到声音……但是什么也没发生。 I have used those Events few months ago on another Android App and then they works fine. 几个月前,我在另一个Android应用程序上使用了这些事件,然后它们运行良好。 Thank you! 谢谢!

Here's standard activate code that should work: 这是应该起作用的标准激活代码:

private var application: NativeApplication; 
application = NativeApplication.nativeApplication; 
application.addEventListener(Event.ACTIVATE, activate); 
private function activate(e: Event): void { 
  //do whatever 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM