Copy link to clipboard
Copied
How can i exit the application when i pressed the power btton in Iphone , My issue is my app have a music but when i press the power button the app goes into the background as a normal feature of iphone but the app music is not stopping at all , is there any way to acheive it ?
Copy link to clipboard
Copied
you can check for an exiting event:
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExit);
function onExit(e:Event):void{
// stop your sound
}
Copy link to clipboard
Copied
Thanks a Lot For reply , is this event works for the power button preess [the Top button of the Iphone] , i was really confufed , my app is going on the background but the music never stoped .
Copy link to clipboard
Copied
yes.
Copy link to clipboard
Copied
I checked this , but it not solves the issue , since when a mobile is not used for a while or the power button on the top is pressed , the application is not exiting , it goes on the background so the code chunk
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExit);
will work when we press the HOME button of the phone , but not the not power button . Do you have any more sugessions
Copy link to clipboard
Copied
basically after some research i found what we probably need to do is to set
" Application does not run in background" to No
is theere any way to specify the same in the in .xml files assosiated with the app .
Copy link to clipboard
Copied
if the app is going into the background, use:
addEventListener(Event.DEACTIVATE, deactivateF);
function deactivateF(e:Event):void{
//stop sound
}
Copy link to clipboard
Copied
Thanks Solved It , I Used A Tag
<key>UIApplicationDoesNotRunInBackground</key><true/>
In the Xml , and itg worked . Thanks a lot for the comments .
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now