Is there a native android way to get a reference to the currently running Activity from a service?
I have a service running on the background, and I would like to up
Is there a native android way to get a reference to the currently running Activity from a service?
You may not own the "currently running Activity".
I have a service running on the background, and I would like to update my current Activity when an event occurs (in the service). Is there a easy way to do that (like the one I suggested above)?
Intent
to the activity -- here is a sample project demonstrating this patternPendingIntent
(e.g., via createPendingResult()
) that the service invokesbindService()
, and have the service call an event method on that callback/listener objectIntent
to the activity, with a low-priority BroadcastReceiver
as backup (to raise a Notification
if the activity is not on-screen) -- here is a blog post with more on this pattern