How to check if Async Task is already running

后端 未结 4 554
一个人的身影
一个人的身影 2020-12-30 19:52

I have an app that needs to do an intensive database operation on start up. The app holds a local copy of the contacts on the phone and synchronizes with the android contact

4条回答
  •  我在风中等你
    2020-12-30 20:32

    Yes Right guys these are some of the examples.

    LoadMusicInBackground lmib = new LoadMusicInBackground();
    
    if(lmib.getStatus() == AsyncTask.Status.PENDING){
        // My AsyncTask has not started yet
    }
    
    if(lmib.getStatus() == AsyncTask.Status.RUNNING){
        // My AsyncTask is currently doing work in doInBackground()
    }
    
    if(lmib.getStatus() == AsyncTask.Status.FINISHED){
        // My AsyncTask is done and onPostExecute was called
    }
    

提交回复
热议问题