Reputation: 917
i need to do a long time job (updating a lot of sql
tables) in onstop
override of an activity but when i close that activity my apps stops working for several seconds . i tried to use AsyncTask
but in that time i get error an error for dialog.dismiss() method in onPostExecute that it says can't attach the dialog to the window ! also i have tried to use services but this method have to be called several times and starting and stopping that service each time didn't work correctly !
i am just mixed up! could you help me with this plz! thanks in advance! :)
Upvotes: 0
Views: 98
Reputation: 50016
IntentService is perfect for such tasks:
http://developer.android.com/reference/android/app/IntentService.html
i have tried to use services but this method have to be called several times and starting and stopping that service each time didn't work correctly !
you simply send jobs to your IntentService, it will take care of initialization and destruction, no need to implement full blown Service.
Upvotes: 2