• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variables afer thread are not being display in the activity?

 
alex friday
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to display magX, mahY, magZ and teslaXYZ variables after the Thread in the acitivity but nothing is being display when I comment the Thread.sleep(10 * 1000); as well try catch block all values are being displayed in the actvity.
I have added the thread to delay the sensor reading, is my appraoch the right way to do that?
Can someone explain me how can I display the variable after the thread in the activity?



I apreciate any help.


 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't call Thread.sleep on the event display thread. You should implement the onPostExecute method in your AsyncTask and use that to update the user interface.

Also read through the tutorial http://www.vogella.com/tutorials/AndroidBackgroundProcessing/article.html" target="_new" rel="nofollow">here which also has an example of how to use AsyncTasks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic