Info
Objective
public void do (){
timer.scheduleAtFixedRate (new TimerTask (){
public void run (){
storedInterface.A ();
}
}, 0, speed);
}
private void startCallback (){
runOnUiThread (new Runnable (){
public void run (){
storedInterface.A ();
}
});
}
public void do (){
timer.scheduleAtFixedRate (new TimerTask (){
public void run (){
startCallback ();
}
}, 0, speed);
}
Posible workaround
Extend SensorClass from an Activity but SensorClass is not an Activity with methods onCreate(), onPause(), etc!!! I don't like this solution.
My question is: How can I call runOnUIThread() within a class that only recieves a context from an Activity? Or... Is there any other solution for my problem?
Thanks.
Solved using handler. Great tool!
public void do (){
final Handler handler = new Handler ();
timer.scheduleAtFixedRate (new TimerTask (){
public void run (){
handler.post (new Runnable (){
public void run (){
storedInterface.A ();
}
});
}
}, 0, speed);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With