ok i found a solution for my problem, hope i will help someone else sometime:
in my BroadCast recevier for Connectivity Changes:
@Override
public void onReceive(Context context, Intent intent) {
//my Application class where i store the last known state of connectivity
app = (AppVariables) context.getApplicationContext();
//new network state
networkState = ((NetworkInfo)intent.getExtras().get("networkInfo")).getState();
if (app.getLastNetworkState().equals(State.CONNECTED) && networkState.equals(State.DISCONNECTED))
{
Log.i("InternetConnectivity", "Internet Status Changed: disconnected");
if (app.getServerConnectionManager() != null)
app.getServerConnectionManager().stopServer(false, false);
if (app.getMainActivity() != null)
app.getMainActivity().showReconnectDialog();
app.setLastNetworkState(networkState);
}
else if (networkState.equals(State.CONNECTED))
app.setLastNetworkState(networkState);
}