In Android: How to Call Function of Activity from a Service? -


I have an activity (A) and a service (s), which is the beginning of A such that:

  intent = new intent (); I.putext ("updateInterval", 10); I.setClassName ("com.blah", "com.blah.S"); StartService (i);  

A has a function like A:

  Public Zero Some Infrared (I Information) {...}  

Now I am using ASM I want to call Infraud (i) from within S There is no version of Intent.putExtra where I can pass an object reference ... Please help!

PS: The other way (there is a voting for new information) is not the way around me that I should get enough information about doing this.

An option is to switch to startService () to bindService () and the local binding pattern Use the. After that, there is no need to call S on any point in order to register you as an audience or callback method. After that, something will happen that will call A when there is some information. You can see a sample project for this.

Alternatively, you can leave startService () and use a broadcast intent to report some information about S You can see a sample project that displays such a broadcast intent .


Comments