How to call AyncTask with listener from a TimerTask in android?
-
29-10-2019 - |
Question
I have to call a Async Task with listener from the TimerTask eack 1.5 seconds.When I tried to do that I'm getting an exception "java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare().". Please help us to solve this issue.
Following is the piece of code I use..
Timer t = new Timer();
TimerTask scanTask = new TimerTask()
{
@Override
public void run()
{
new BgTask((BgTaskListener)this).execute("","currentState");
}
};
t.schedule(scanTask, 1500, 1500);
Here BgTask id the AsyncTask class.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow