aspose file tools
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
Register / Login


JavaRanch » Java Forums » Mobile » Android
Reply 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: 35443
    
    9
You would send an Intent to it that is targeted at its precise class. Something like this in the Activity:

and in the Service:


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Passing a variable from Activity to a running Service?
 
Similar Threads
Android application lifecycle
Multiple Classes in the Same package-Axis
How to send continous data from serice to activity?
Regarding Remote Service
Multiple Classes in the Same package - AXIS