Extending AsyncTask

前端 未结 4 1890
礼貌的吻别
礼貌的吻别 2020-12-13 13:41

In my android app I am performing some operations in the doInBackground by extending AsyncTask class. (I have no use in per

4条回答
  •  鱼传尺愫
    2020-12-13 14:13

    Is this proper use of AsyncTask ?

    You don't said what is your goal. But AsyncTask is generally used for long tasks and updating UI during work exactly to notify some progress change of some long work. It's also very efficient, type-safe tool and more complex than Handler for example.

    What is the difference between extending AsyncTask and AsyncTask

    AsyncTask is generic type and you should use generics with them is code more faster, more type-safe.

    I have no use in performing any UI

    So you rather can use Handler or classical Runnable interface and you can work only with worker threads basically.


    Note: Generally, using of generics types makes code faster, most type-safe. Also next advantage is strong type checking at compile source code, restrictions of explicit conversions etc.

提交回复
热议问题