I have a service that is downloading a file. When the download is done, I would like to update my \"Downloaded files\" list in my Activity, but only if the
You can create new BroadcastReceiver instance and do something along these lines on your Activity's onResume() method:
registerReceiver(myReceiver, new IntentFilter(DownloadService.ACTION_FILE_DOWNLOADED));
After that, override myReceiver's onReceive() method to call a function that updates the component you want:
@Override
public void onReceive(Context context, Intent intent) {
...
updateViewWithData(service.getNewFileData());
...
}
On your Activity's onPause() method, just unregister the receiver:
unregisterReceiver(myReceiver);
I hope that this would help you, feel free to ask if there is something unclear.