public void startBackgroundJob ( int msgId , Runnable runnable ) { // make the progress dialog uncancelable, so that we can guarantee // that the thread is done before the activity gets destroyed ProgressDialog dialog = ProgressDialog . show ( this , null , getString ( msgId ) , true , false ) ; Job < Object > managedJob = new Job < Object > ( runnable , dialog ) ; managedJob . runBackgroundJob ( ) ; }
Start a background job showing a progress bar as long as the job runs . This seems contradictory but with background job we mean one that runs off the ui thread to prevent an ANR . We still have to wait for the processing to be done because we need the result .