I'd like to send http requests every N seconds. The response should be shown is some textViews.
I got error that "Can't create handler inside thread that has not called Looper.prepare()"
My code is below:
private void runTimer() {
MyTimerTask myTask = new MyTimerTask();
Timer myTimer = new Timer();
myTimer.schedule(myTask, 3000, 1500);
}
class MyTimerTask extends TimerTask {
public void run() {
asyncGetRequest();
}
}
private void asyncGetRequest(){
new DownloadWebPageTask().execute("http://www.google.com");
}
....
//this method is called automatically after receiving http response
@Override
protected void onPostExecute(String result) {
someTextView.setText("some text");
}
Thanks!!!
0 comments:
Post a Comment