Permalink
Browse files

Fix for yaxim not reconnecting after intermittent network loss

For intermittent network loss where android is able to reconnect to
the same network, the broadcast receiver will not get a "DISCONNECT"
notification.
To reconnect when the receiver gets the new "CONNECT", the networkType
needs to be reset, otherwise the receiver will not reconnect.
  • Loading branch information...
1 parent 5544bed commit d8babb72e9119a11ed876d5f845fabd6bbdb5682 @tuxmobil committed May 7, 2012
@@ -416,6 +416,7 @@ private void connectionFailed(String reason) {
mSmackable.unRegisterCallback();
mSmackable = null;
}
+ YaximBroadcastReceiver.initNetworkStatus(getApplicationContext());
} else if (mConnectionDemanded.get()) {
mReconnectInfo = getString(R.string.conn_reconnect, mReconnectTimeout);
updateServiceNotification();
@@ -15,6 +15,7 @@
public static void initNetworkStatus(Context context) {
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
+ networkType = -1;
if (networkInfo != null) {
Log.d(TAG, "Init: ACTIVE NetworkInfo: "+networkInfo.toString());
if (networkInfo.isConnected()) {

0 comments on commit d8babb7

Please sign in to comment.