Note that there are some explanatory texts on larger screens.

plurals
  1. POrunOnUiThread stops Working When Application is Destroyed
    text
    copied!<p>So here's what happening: I'm using the runOnUiThread() method to change an Image View from another class when that class receives a message from another phone. I'm calling it by using mainclass.runOnUiThread(new Runnable...) and so on. It works the first time the application is run, but when I hit the back button to exit the application, and then launch the application again, the Image View no longer updates. The logs I took shows me that everything is fine and being run, but the Image View doesn't change. I don't get any errors and it doesn't crash when I run the application, it just doesn't update the Image View. Any idea what might be causing this?</p> <p>Edit*: So this is what i'm actually using to change the imageView in a class that doesn't extend Activity</p> <pre><code>peerActivity.runOnUiThread( new Runnable(){ @Override public void run() { Log.v("Thread@", "Thread is running"); Log.v("Thread@2", decodedImage.toString()); // TODO Auto-generated method stub peerActivity.ivPhoto.setImageBitmap(decodedImage); Log.v("Thread@3", "Past UI Change"); } }); </code></pre> <p>Where peerActivity holds the other class reference and ivPHoto is the Image View. What I think I need to do is find a way to kill that thread when the program closes (when I go into the program manager, it still has the Force Close button available). Is there any way to do this?</p> <p>Edit2*: So I tried a bunch of different approaches to working on the UI Thread and they all give me the same result: The program works perfectly the first time its run but when I hit the back button and close it and the re-open it, the Image View no longer updates. If I force close the app, it works fine again until I close it and re-open it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload