Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing a variable from Activity to a running Service?  RSS feed

 
Sean Michael Hayes
Ranch Hand
Posts: 54
Android
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would be the best way of accomplishing this? The service is started on start-up of the application when the first activity loads. But later on in the application in a different specific activity I want to pass a variable to the service? I am new to services in Android and am wondering if anyone could point me in the right direction?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would send an Intent to it that is targeted at its precise class. Something like this in the Activity:

and in the Service:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!