implement basic poll

This commit is contained in:
B. Petersen
2018-05-18 18:54:01 +02:00
parent 6ce08ef461
commit faacf510b2
3 changed files with 14 additions and 2 deletions
@@ -169,7 +169,8 @@ public class ApplicationLoader extends Application {
// start keep-alive service that restarts the app as soon it is terminated
// (this is done by just marking the service as START_STICKY which recreates the service as
// it goes away which also inititialized the app indirectly by calling this function)
applicationContext.startService(new Intent(applicationContext, KeepAliveService.class));
//applicationContext.startService(new Intent(applicationContext, KeepAliveService.class));
// init locale
try {
@@ -29,6 +29,9 @@ import android.app.Application;
import android.os.Build;
import android.os.Bundle;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.Utilities;
import java.util.concurrent.CopyOnWriteArrayList;
@SuppressLint("NewApi")
@@ -85,6 +88,8 @@ public class ForegroundDetector implements Application.ActivityLifecycleCallback
}
}
}
MrMailbox.connect();
}
public boolean isWasInBackground(boolean reset) {
@@ -111,6 +116,12 @@ public class ForegroundDetector implements Application.ActivityLifecycleCallback
}
}
Utilities.searchQueue.postRunnable(new Runnable() {
@Override
public void run() {
MrMailbox.disconnect();
}
});
}
}
@@ -51,7 +51,7 @@ public class TimerReceiver extends BroadcastReceiver {
Utilities.searchQueue.postRunnable(new Runnable() {
@Override
public void run() {
MrMailbox.heartbeat();
MrMailbox.poll();
}
});