Android, can I put AsyncTask in a separate class and have a callback?

前端 未结 3 1036
一整个雨季
一整个雨季 2020-12-03 02:02

I\'m just learning about AsyncTask and want to use it as a separate class, rather then a subclass.

For example,

class inetloader extends AsyncTask&l         


        
3条回答
  •  無奈伤痛
    2020-12-03 02:15

    inetloader il = new inetloader();
    il.execute("http://www.google.com");
    
    String result = il.get();//put it in try-catch
                    ^^^^^^^^ 
    

    here you get result which is in onPostExecute(String result)

提交回复
热议问题