Reputation: 372
I want to develop a chat application. In that, when the application is in foreground, everything is working fine. However, when the application is minimized, I want to show notifications to user that new message has arrived. If the user does not respond to that message within 1 minute, the message will be deleted.
So here is what I am doing:
All of above works fine when the application is active (meaning in foreground).
But when the application is in background (minimized and new message is coming), the notification is shown and my timer starts, but the UI is not updating.
I tried putting code in runOnUIThread but that didn't work.
Anyone have any ideas on how I can implement this?
Upvotes: 1
Views: 329
Reputation: 4256
The problem is that the application is in pause mode when its not on the foreground.
You can however update the UI in the onResume method. Whenever the user reopens the application onResume will be called and the UI will get executed.
Upvotes: 3