Reputation: 23
I'm working now in a project to download images from the web and then show it after completing its download.
i made an activity class that has a button and text field and when the user press on the button, i started a service which will show a notification in status bar and after download i will show a message .
my main problem now is i want to go to other application or home page while the download is working.
i tried it but i after the download i got the message ,,, " Force quit"
should i use broadcast receiver or remote server to handle what i want.
Thanks,
Upvotes: 0
Views: 231
Reputation: 840
Activities are just that, activities, they only work when visible and are built strictly for user interaction or a user activity, so this is impossible. Use a service instead. Here is a diagram showing lifespan of an activity:
Link to App activity explanation on Android developer site
Upvotes: 1
Reputation: 5759
You may need to call Looper.Loop()
in your service to keep it running if you have any listeners in your service.
Upvotes: 0
Reputation: 14237
The service should be the one downloading the content. If you go to the home activity our activity calls onPause
, stoping all the work in progress.
Upvotes: 2