I tried https://github.com/pubnub/java/tree/master/android#connection-durability-reconnecting--resuming-when-a-connection-is-lost-or-changed but still I'm not able to figure out how to use setResumeOnReconnect() . I'm running android-service and added following code snippet inside onCreate() of the service.
pubnubBroadcastReceiver =new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
int networkType = intent.getExtras().getInt(ConnectivityManager.EXTRA_NETWORK_TYPE);
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(networkType);
boolean isConnected = networkInfo.isConnected();
if(isConnected) {
ApplicationLoader.getPubnub().disconnectAndResubscribe();
// ApplicationLoader.getPubnub().setResumeOnReconnect(true);
}
}
};
registerReceiver(pubnubBroadcastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Don't know what I'm missing here.