public class NetstateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityManager manager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo gprs = manager
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
NetworkInfo wifi = manager
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (!gprs.isConnected() && !wifi.isConnected()) {
// network closed
} else {
// network opend
}
}
}