Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class MyNetworkConnectedReceiver extends BroadcastReceiver {
private Context _context;
public void onReceive(Context context, Intent intent) {
_context = context;
ConnectivityManager connectivityManager = ((ConnectivityManager) context
NetworkInfo currentNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (currentNetworkInfo != null && currentNetworkInfo.isConnected()) {
//do something when network connected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment