I'm new to Android development and I would like to know what is the best practice to update the UI from another class.
Example: When I enter an activity I start a function myClass.PerformCalculation()
which takes some time, when the calculation is over I want to update the UI with the result of the calculation.
This generates the following error:
CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
I was thinking about using a Broadcast Receiver in the activity and perform a SendBroadcast
at the end of myClass.PerformCalculation()
, is it a good practice?