Waiting for a function to finish execution and using the results

后端 未结 2 765
伪装坚强ぢ
伪装坚强ぢ 2021-01-25 12:05

Here\'s the scenario

I have an activity(A) which has a button and textview. I have another class(B) with methods for performing various functions. After creating an inst

2条回答
  •  借酒劲吻你
    2021-01-25 12:24

    When you create an instance of class B make sure it takes Context as an argument in its constructor. Then you can try using AsyncTask (Assuming you know it). Then put the time consuming function in doInBackground() and the function which waits for its values in onPostExecute()

提交回复
热议问题