App Bug fix: Events were not sent anymore when the network connectivity is lost once, regained and the handler tries to send the events but the network connectivity is lost again

This commit is contained in:
Armin Zamani committed 2013-05-02 01:35:06 +02:00
1 parent 6eec1d8efd
commit b5f691ee21
2 files changed
+10 -3

No files matched your search

@@ -12,8 +12,11 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.sap.sailing.racecommittee.app.R;
import com.sap.sailing.racecommittee.app.logging.ExLog;
public class ConnectivityChangedReceiver extends BroadcastReceiver {
private final static String TAG = ConnectivityChangedReceiver.class.getName();
/* (non-Javadoc)
* @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
@@ -37,6 +40,7 @@ public class ConnectivityChangedReceiver extends BroadcastReceiver {
ComponentName receiver = new ComponentName(context, ConnectivityChangedReceiver.class);
PackageManager packageManager = context.getPackageManager();
packageManager.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
ExLog.w(TAG, "Regained connectivity. ConnectivityChangedReceiver disabled");
}
/**
@@ -47,6 +51,7 @@ public class ConnectivityChangedReceiver extends BroadcastReceiver {
ComponentName receiver = new ComponentName(context, ConnectivityChangedReceiver.class);
PackageManager packageManager = context.getPackageManager();
packageManager.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
ExLog.w(TAG, "Connectivity lost. ConnectivityChangedReceiver enabled");
}
}
@@ -152,6 +152,7 @@ public class EventSendingService extends Service implements EventSendingListener
ExLog.i(TAG, String.format("Send aborted because there is no connection."));
persistenceManager.persistIntent(intent);
ConnectivityChangedReceiver.enable(this);
serviceLogger.onEventSentFailed();
} else {
sendEvent(intent);
}
@@ -163,10 +164,11 @@ public class EventSendingService extends Service implements EventSendingListener
isHandlerSet = false;
if (!isConnected()) {
ExLog.i(TAG, String.format("Resend aborted because there is no connection."));
return;
ConnectivityChangedReceiver.enable(this);
serviceLogger.onEventSentFailed();
} else {
sendDelayedEvents();
}
sendDelayedEvents();
}
private void sendDelayedEvents() {