hello I have a problem with java and android develop a dual timer with the Runnable class.
By means of a call first the activity mRunnable and then the mRunnable1 at a distance of a few seconds. The problem is that when viewing the screen "DownTot.setText (a);" show me for a moment and then subsequently rxbytes the difference (rxbytes - rxbytes1). This is done as if the operation was slow. is there a way to optimize my code?
Here is the code below:
public class MainActivity extends Activity implements OnClickListener { TextView DownTot; private long rxBytes; private long rxBytes1; private final Runnable mRunnable = new Runnable() { public void run() { mHandler.postDelayed(mRunnable1, 1000); TextView DownTot = (TextView)findViewById(R.id.downtot); rxBytes = (TrafficStats.getTotalRxBytes()- StartDown); long a = rxBytes - rxBytes1; DownTot.setText(a); } }; private final Runnable mRunnable1 = new Runnable() { public void run() { mHandler.postDelayed(mRunnable1, 1000); TextView DownTot = (TextView)findViewById(R.id.downtot); rxBytes1 = (TrafficStats.getTotalRxBytes()- StartDown); long a = rxBytes1 - rxBytes; DownTot.setText(a); } }; ......