AsyncTask return value

前端 未结 4 1597
死守一世寂寞
死守一世寂寞 2020-12-05 06:47

My android app connects to my website to retrieve and upload information so I use an AsyncTask thread.

In one instance, I need my thread to return a true or a false

4条回答
  •  星月不相逢
    2020-12-05 07:41

    Here is a complete example of the issue of returning values from an async task. It may occur that there are many tasks to be done one after the other asynchronously.

    Basics. 1. get a return value from a class.

    public class Snippet {
    int computVal;
    public Snippet(){
        computVal = 17*32; 
    }
    public int getVal(){
        return computVal;
    }   
    

    }

    this is called as...

    int hooray = (new Snippet()).getVal();
    

提交回复
热议问题