|
|
@ -63,7 +63,7 @@ import javax.mail.internet.MimeMessage;
|
|
|
|
|
|
|
|
|
|
|
|
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
|
|
|
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
|
|
|
|
|
|
|
|
|
|
|
public class ServiceSend extends ServiceBase {
|
|
|
|
public class ServiceSend extends ServiceBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
|
|
|
private TupleUnsent lastUnsent = null;
|
|
|
|
private TupleUnsent lastUnsent = null;
|
|
|
|
private boolean lastSuitable = false;
|
|
|
|
private boolean lastSuitable = false;
|
|
|
|
|
|
|
|
|
|
|
@ -150,12 +150,16 @@ public class ServiceSend extends ServiceBase {
|
|
|
|
iif.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
|
|
|
iif.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
|
|
|
iif.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
|
|
|
iif.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
|
|
|
registerReceiver(connectionChangedReceiver, iif);
|
|
|
|
registerReceiver(connectionChangedReceiver, iif);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onDestroy() {
|
|
|
|
public void onDestroy() {
|
|
|
|
EntityLog.log(this, "Service send destroy");
|
|
|
|
EntityLog.log(this, "Service send destroy");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
|
|
|
|
|
|
|
|
|
|
|
|
unregisterReceiver(connectionChangedReceiver);
|
|
|
|
unregisterReceiver(connectionChangedReceiver);
|
|
|
|
|
|
|
|
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
@ -172,6 +176,12 @@ public class ServiceSend extends ServiceBase {
|
|
|
|
super.onDestroy();
|
|
|
|
super.onDestroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
|
|
|
|
|
|
|
if (ConnectionHelper.PREF_NETWORK.contains(key))
|
|
|
|
|
|
|
|
checkConnectivity();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
|
super.onStartCommand(intent, flags, startId);
|
|
|
|
super.onStartCommand(intent, flags, startId);
|
|
|
|