Extending AsyncTask

前端 未结 4 1779
礼貌的吻别
礼貌的吻别 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:04

    1. is this proper use of asynctask?

    I don't think there is any proper use. You can use asynctask to perform intensive operations on background thread and publish result, updates on main thread. It's not mandatory that you must publish result or progress. That's given to you. Your decision.

    But for your network operations, you can use thread also. But later you decided to publish result and progress on main thread, Asynctask will help you in a simple way.

    Threads don't.

    Asynctask uses generic datatypes as parameters. You must provide it. If you don't want to provide or accept any data from asyctask. You can use Void type,

    just like given below

    class MessagePooling extends AsyncTask
    

    It means asynctask will get no parameters, give you no progress or result.

    For more about asynctask: http://androidride.com/beginners-guide-asynctask-android-tutorial-example/

提交回复
热议问题