Who launch service

Put your problem here if it does not fit any of the other categories.

Who launch service

Postby dani.vitali » Wed Feb 29, 2012 11:05 am

Hi guys!

I would like to know if it's possible to know which activity has launched a service.
For example: I have an activity that send an intent to a service. From the service class constructor I would like to have the reference to the class which launch the intend.

Is that possible?

Thank you in advance! :D
dani.vitali
Freshman
Freshman
 
Posts: 2
Joined: Thu Feb 23, 2012 6:44 pm

Top

Re: Who launch service

Postby Phyll » Wed Feb 29, 2012 1:14 pm

Hi dani.vitali,

I don't think the sender is part of the intent so it is not available to get. You might send some piece of data with it when you start it I guess, that way, you would know it was from your app. Others would not send it and you would know it was from some other app. Something like that.

Of course any app that knows what to do with your service could send it information about itself. Otherwise, if your app is just registered to handle certain things and apps just broadcast for the app that best handles their content, well you can see the problem. They wouldn't know whether your app was going to handle it or not. But all of your activities that require that service could.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Who launch service

Postby nuetronprotron » Mon Mar 05, 2012 1:52 pm

Hi dani,
As Phyll stated, we cannot get the information about the originator of the service,but if you needed u can send from the service by having a varible of the originator or just send through an intent while replying from service.

This is mainly due to the behavior of android towards the creation of services,android creates these services as deamon threads which never die literally.
nuetronprotron
Developer
Developer
 
Posts: 37
Joined: Tue Jan 10, 2012 10:22 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 25 guests