Skip to content

Commit 3c826b1

Browse files
author
Geremy Cohen
committed
Update android/README.md
1 parent 1a56358 commit 3c826b1

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

‎android/README.md‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,32 @@ calls **disconnectAndResubscribe()** as needed.
3636
```java
3737

3838
public boolean haveInternet(Context ctx) {
39-
4039
NetworkInfo info = (NetworkInfo) ((ConnectivityManager) ctx
4140
.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
4241

4342
return ( info != null && info.isConnected());
4443
}
4544

46-
protected void onCreate(Bundle savedInstanceState) {
47-
45+
protected void onCreate(Bundle savedInstanceState) {
4846
...
49-
5047
this.registerReceiver(new BroadcastReceiver() {
5148

5249
@Override
5350
public void onReceive(Context arg0, Intent intent) {
54-
boolean haveInternet = haveInternet(arg0);
51+
boolean haveInternet = haveInternet(arg0);
5552

56-
if ( haveInternet != networkConnected) {
57-
Log.d("Receiver 1", "Network state changed from " + networkConnected + " to " + haveInternet);
53+
if ( haveInternet != networkConnected) {
54+
Log.d("Receiver 1", "Net state changed from " +
55+
networkConnected + " to " + haveInternet);
5856
}
5957

60-
if (haveInternet && !networkConnected ) {
61-
pubnub.disconnectAndResubscribe();
62-
}
63-
networkConnected = haveInternet;
64-
65-
}
66-
}, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION ));
67-
58+
if (haveInternet && !networkConnected ) {
59+
pubnub.disconnectAndResubscribe();
60+
}
61+
62+
networkConnected = haveInternet;
63+
}
64+
}, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION ));
6865
....
6966
}
7067
```

0 commit comments

Comments
 (0)