-1

Possible Duplicate:
When I exit an application the sound runs on the background

When i click the home button or back button, the audio/sound still running, the source of the audio is swf(flash) so how can i fix it? i heard something like onpause or something like that...

Community
  • 1
  • 1
Gil Ralph
  • 21
  • 1
  • 5
  • Hmm, you are asking the same question 5th time - it won't help you, believe me. Also, this is a very basic question, you should probably start reading Android docs. – Code Painters Sep 29 '12 at 17:13
  • I know... i try again and again like 6 hours! to try understand all the guides over about activity... but i don't understand nothing from this. i spend 6 hours + - to understand something from all the guides but i get errors... and cant understand.( i think i cant understand because they talk about music files and i talk about swf.. – Gil Ralph Sep 29 '12 at 17:33
  • Do you mean that you have a Flash file inside of a `WebView`? In that case, see [How do I pause Flash content in an Android WebView when my activity isn't visible?](http://stackoverflow.com/q/3431351/687315). – quietmint Sep 29 '12 at 17:39
  • Yep!!!! men thanks a lot! Thanks a lot men! – Gil Ralph Sep 29 '12 at 17:41

1 Answers1

0

You heard right :-) The Activity class provides on onPause() method, which is called as soon as your Activity is paused, which is the case when it's no longer visible. So you could just overwrite onPause() and pause your sound. To resume it when the Activity becomes visible again, overwite onResume(). Also have a look at the Activity lifecycle, which every Android developer should know be heart.

Ridcully
  • 23,362
  • 7
  • 71
  • 86
  • Actually, for knowing it by heart, you should suggest `onStop()` instead. "The visible lifetime of an activity happens between a call to `onStart()` until a corresponding call to `onStop()`". Don't pause the audio in `onPause()` because the application is still visible (e.g., a dialog is present)... unless that's really what you want. – quietmint Sep 29 '12 at 17:14
  • i try it thanks! the problem i need it for swf(flash) file... and i think its little different from other media file. – Gil Ralph Sep 29 '12 at 17:34