• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to play audio in the background  RSS feed

 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a good way to play streaming audio in the background so that audio continues to play while the user switches between activities of the app, but stops whenever, for example, the user has an incoming phone call?
 
Ranch Hand
Posts: 132
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use a Service to play audio cause it will call the AUdio Service in Android
 
Daniel Trebbien
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Michael Rivera wrote:use a Service to play audio cause it will call the AUdio Service in Android



Do you know of a good tutorial for this?
 
Ranch Hand
Posts: 136
Android Chrome Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel,

You can use AsyncTask to continue playing audio even if user switches or move to another screen.

Thanks & Regards
Pratik Goswami
 
Rancher
Posts: 42974
76
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can use AsyncTask to continue playing audio even if user switches or move to another screen.


That's not a good idea, as AsyncTask's are part of the Activity, and thus eligible for termination whenever Android feels like it. Services are better suited for longer-running tasks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!