次のコードを使用して、一定時間後にリストを更新しています。
Myactivity {
setTimer() {
Runnable r = new Runnable() {
run() {
if(!isListUpdated) {
update();//n/w operation
} else {
show();//this is a UI operation
listupdated = false;
}
Handler.postDelayed(this,next); //repeat after next
}
new Thread(r).start();
}
}
}
2〜3回の繰り返しの後、それはNetworkOnMainThreadException
. このコードのどこが間違っているのか誰か教えてもらえますか?