Here’s my app layout.
MainActivity
|
Service
|__Handler
|__Runnable
In the Runnable I retrieve a String from the internet. It’s small enough to fit in an intent, if that matters.
I want to pass the String all the way back to MainActivity and notify it that it has been updated.
How can I do this?
Two methods:
Both require to put the result as String Extra, in the Intent.
I suppose your Handler and Runnable are inline-class under Service, so you can have access to the
Context. If not, you have to pass the Service Context to those classes.Nope, any class can call
Context.sendBroadcastorContext.startActivity, and it does not require to be done on the Main Thread.