DownloadManager
- Attach a BroadcastReceiver to listen for DownloadManager.ACTION_DOWNLOAD_COMPLETE.- Finish the (only) Activity. At this point the app process will still run
- Disable wifi
Result: the app process will be killed, no broadcast received when the download is paused, nor when the framework continues and finishes the download.
Broadcasts
Broadcast will be received even if the app is in the background, if BroadcastReceiver was registered. It is just a good practice to unregister it if not needed (because it may consume resource in vain). So generally you should unregister onPause() if you registered it onResume(). Test code.If you register the broadcast receiver with the activity's context, it will receive broadcasts as long as the activity is alive. However, you can register the receiver with the applicatino context, and it will still receive broadcasts even if the activity isn't alive. cited from here
No comments:
Post a Comment