Any way to run a background thread behind multiple Activity and show alert when done?
My application is 开发者_StackOverflow中文版using a REST based webservice to show multiple activity. To enable the user offline browsing, I am storing the REST data into local SQLiteDatabase with AsyncTask (with some dialogue to wait). However, it takes a long time to load the db (10 mins) and its just bad experience for the user. So I was wondering if there is a way to run the DBLoading thread in background and let the user continue using the app (With multiple activity) with the REST service. When DBLoading thread is done, I want to push a notification in the current Activity in focus letting the user know the Loading is done.
You can run it in a service and let the service inform your activities or your currently focused activity of certain events.
It's actually just a simple observer pattern.
精彩评论