How to get XML using AsyncTask and Timer?

后端 未结 5 908
星月不相逢
星月不相逢 2020-12-15 01:44

In order to get XML data from a server repeatedly, I\'m attempting to use AsyncTask and Timer as per Mark Murphy\'s suggestion.

I get the following error:

         


        
5条回答
  •  春和景丽
    2020-12-15 02:28

    The problem seems to be that you haven't called Looper.prepare(). You could have a look at the documentation for Looper.

    A Handler needs a message loop in order to process messages and a Thread by default doesn't have one.

    It seems that AsyncTask uses a Handler internally so add Looper.prepare() at the top of your run() method in MyTimerTask and that should solve your problem.

提交回复
热议问题