• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Accessing and intent from a Service?

aryaxt

Newbie
Jun 1, 2010
21
0
I have a service running in the background. (A socket class)
When the socket receives message i need to access the Activity that is shown on the screen and update the gui, any idea how i can manage to get the Activity shown to the user?
Thanks.
Code:
public void socketGotMessage(String message)
{
     if (message == "chat")
     {
            Activity myTopActivity = //somehow get the top activity
            myTopActivity.displayChatMessage("You got a message");
     }
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones