use AsyncTask in your service to work with a heavy database.
and use General Preferences to save the flag to notify of other activities that work in the process. When flag is true means "Work in progress" and the flag "false" means "Work".
Do something like this:
private class DatabaseWork extends AsyncTask<String, Integer, Long> { protected void onPreExecute () {
}
Now you can check the value of the SharedPref flag for each onCreate or onResume action. If you find true, you can display a progress dialog so that the user can wait.
source share