Step 1:
Create Object in java class:-
Handler handler = new Handler();
Runnable refresh;
Step2: Call your method like dataSpeed will call every 10ms
refresh = new Runnable() {
public void run() {
dataSpeed();
handler.postDelayed(refresh, 10);
}
};
handler.post(refresh);