0

I have an activity in which i trigger a thread, That thread is updating the ui elements on that same activity. When activity goes background, the thread is still running, but when i resume activity, the thread is running but not updating UI. Can anyone help me out with this?

Suresh Sharma
  • 57
  • 1
  • 9
  • https://developer.android.com/guide/components/processes-and-threads – Zun Dec 03 '18 at 10:20
  • 1
    the views are destroyed when you leave the app and they are recreated again when you come back to the app. They are not the same. To avoid this use livedata with viewmodel. – Pemba Tamang Dec 03 '18 at 10:45

1 Answers1

1

You can use Broadcast Receiver to update the the UI from different Thread. Register the Broadcast receiver inside onResume() and Update the UI inside onreceive() of Broadcast Receiver.

Check below link for referrence.

https://stackoverflow.com/a/25216606/4657385

Sabyasachi
  • 3,499
  • 2
  • 14
  • 21