Hope this helps. No matter what activity you perform, the download should create a BroadcastReceiver that can handle connection status notifications. You will then be notified that the connection has dropped and can handle it more elegantly ... for example, waiting for a notification about the return of connections and a restart of the download:
private BroadcastReceiver mConnReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean missingConnection = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); String reason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
This page also has good info: http://thiranjith.com/2011/03/31/how-to-monitor-network-connectivity-in-android/
source share