Last active
January 19, 2016 13:02
-
-
Save ArcherN9/076f77fc123a986e22d0 to your computer and use it in GitHub Desktop.
This gist answers the question posted at https://github.com/nostra13/Android-Universal-Image-Loader/issues/1153.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onResume() { | |
super.onResume(); | |
//Register broadcast receiver to receive changes in connectivity | |
registerReceiver(brConnectivityChangeReceiver, new IntentFilter( | |
"android.net.conn.CONNECTIVITY_CHANGE" //Ideally, put this in the strings.xml file | |
)); | |
} | |
private BroadcastReceiver brConnectivityChangeReceiver = new BroadcastReceiver() { | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
//Get reference to the ConnectivityManager to retrieve network info object | |
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
//Get Network Info to access current connection type | |
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); | |
//Check if connected internet type is WiFi or not | |
if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) | |
ImageLoader.getInstance().displayImage(url, imageView, imageLoadingListener); //Attempt to load image again | |
else | |
Log.i(TAG, "Don't have Wifi Connection"); //Do nothing here since the user has already been prompted once to turn on wifi | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment