In my Android app, I have some code that is running in the background, in its own thread. This code contacts a server on the network to acquire data. Once that data is acquired, I need to be able to access my activity's view so that I can change data on the screen (images, text, etc.). Here is the way my packages are set up:
|- Java
| `- myMainPackage
| |- subPackage01
| | `- classIWantToAccessMyLayoutFrom.java // different thread
| |- subPackage02
| |- subPackage03
| `- subPackage04
| |- subSubPackageA
| | `- MainActivity.java
| |- subSubPackageB
| |- subSubPackageC
| | `- MyLayout.java
| `- subSubPackageD
|
`- res
|- drawable
|- layout
| |- activity_main.xml
| `- my_layout.xml
`- values
I just cannot figure out how to get access to the activity from within classIWantToAccessMyLayoutFrom.java. Do I pass the activity into classIWantToAccessMyLayoutFrom.java in the constructor when it is created, or is there a better, more "slick" way, to do it?
If I pass it to the thread's constructor, I will have to pass the activity through all of the other classes until it gets to the actual class that needs it. It just seems like there should be a better way. Is there?