This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Android and the fly likes Passing a variable from Activity to a running Service? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Passing a variable from Activity to a running Service?" Watch "Passing a variable from Activity to a running Service?" New topic
Author

Passing a variable from Activity to a running Service?

Sean Michael Hayes
Ranch Hand

Joined: Feb 08, 2012
Posts: 54

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
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
You would send an Intent to it that is targeted at its precise class. Something like this in the Activity:

and in the Service:


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing a variable from Activity to a running Service?