java - updating notification text every second with handler -


I have a strange problem. I want to update the notification text per second, so I wrote this code

  new handler () Post Delayed (New Runnabal) {@Override Public Zero Run () TODO Auto-Specified Method Stub Battery Temperature = getBatteryTemperature (); New handler () Post Delaned (this, 1000);}}, 1000); If (battery temperature! = 0) {builder.setContentText ("battery level" + battery temperature); } Else {builder.setContentText ("The importance of battery temperature is 0"); }   

I saw with a log that the battery temperature in handler is different from 0 but outside the handler it is returned to 0. Why? How can I determine the right value in the notification?

  last handler handler = new handler (); Handler.Post Delayed (New Runnabal) {@ Override Public Wide Run (BatteryPatent = Thanck Battierepanner); Handler. Post Delayed (this, 1000);}}, 1000);   

Do not create a handler every time it is called Runnerble. You need to execute this snippet, runnable is executed every time

  if (battery temperature! = 0) {builder.setContentText ("BatteryLevel" + battery temperature); } Else {builder.setContentText ("The importance of battery temperature is 0"); }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -