[android-developers] Re: Start and Stop music on application launch and stop

2010-01-05 Thread tobias429
Hi Hassan,

You can use the onPause() and onResume() functions for this. Just
override the original functions and place the code to start your sound
in onResume() and the code to stop your sound in onPause().

In case you have several activities that can be independently started
and stopped, I'd use a static class with a counter of how many
activities are active right now. Every time an activity executes
onResume(), increase the counter by one, every time onPause() is
called, decrease it by one. You can then stop your sounds in onPause()
in case the counter is set to zero. Ditto for onResume(), where you
only need to start your sound in case that static counter was zero
beforehand.

Haven't tried this though, just an idea.

Best regards,

Tobias

On Jan 5, 7:14 am, Hassan Imtiaz hassan.imt...@cprods.com wrote:
 Hi,
     In my application i have several activities and i want to start
 background music whenever my *Application* is launched and stop music
 whenever *Application* is paused or stopped.
     Any help?.

 Regards,
 Hassan Imtiaz

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Start and Stop music on application launch and stop

2010-01-05 Thread Hassan Imtiaz
Thanks Tobias,

Actually in my activities there is an activity that i am using through jar
file and when i press home button of device at that particular activity,
application is paused but there is no way i can override the onpause()
function of that activity to stop music.So how can i stop music in this
case?

Best Regards,
Hassan Imtiaz


On Tue, Jan 5, 2010 at 2:38 PM, tobias429 ecker...@gmx.de wrote:

 Hi Hassan,

 You can use the onPause() and onResume() functions for this. Just
 override the original functions and place the code to start your sound
 in onResume() and the code to stop your sound in onPause().

 In case you have several activities that can be independently started
 and stopped, I'd use a static class with a counter of how many
 activities are active right now. Every time an activity executes
 onResume(), increase the counter by one, every time onPause() is
 called, decrease it by one. You can then stop your sounds in onPause()
 in case the counter is set to zero. Ditto for onResume(), where you
 only need to start your sound in case that static counter was zero
 beforehand.

 Haven't tried this though, just an idea.

 Best regards,

 Tobias

 On Jan 5, 7:14 am, Hassan Imtiaz hassan.imt...@cprods.com wrote:
  Hi,
  In my application i have several activities and i want to start
  background music whenever my *Application* is launched and stop music
  whenever *Application* is paused or stopped.
  Any help?.
 
  Regards,
  Hassan Imtiaz

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Start and Stop music on application launch and stop

2010-01-05 Thread Peter SSK
How to play music in android?...
You have any suggestion related this?..
If so pls give some idea for that or example program.

On Jan 5, 11:14 am, Hassan Imtiaz hassan.imt...@cprods.com wrote:
 Hi,
     In my application i have several activities and i want to start
 background music whenever my *Application* is launched and stop music
 whenever *Application* is paused or stopped.
     Any help?.

 Regards,
 Hassan Imtiaz
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en