目标-保持同步会话 Andriod Gradle Settigs:androidx,Realm Lib-5.12.0,Gradle 3.4.1 面临的问题:每隔5分钟,部分Realm Sync会话就会断开连接,需要2分钟才能重新与Realm Cloud Server重新连接
我每隔20秒点击一次领域文件,以保持连接会话唤醒,我正在Thread上执行此操作
SyncManager.refreshConnections(); // it not work for me
syncTimer=new Timer();
syncTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
try {
if(LoopHealthApplicationClass.getInstance().physicianUser!=null && LoopHealthApplicationClass.getInstance().physicianUser.getPhysicianId()!=null) {
boolean chatBoolean=ChatSyncDao.addChatSyncAt(LoopHealthApplicationClass.getInstance().physicianUser.getPhysicianId());
boolean userBoolean=SyncDao.addUserSyncAt(LoopHealthApplicationClass.getInstance().physicianUser.getPhysicianId());
Timber.d("chatRealm: "+chatBoolean+" | userRealm: "+userBoolean+"| SyncAt");
}
}catch(Exception e) {
e.printStackTrace();
SyncManager.refreshConnections(); //Refresh Connection
}
}
}, 20000, 20000);
如果它断开连接,我想维持Realm Sync会话,它应该自动连接或我可以用来与云同步重新连接的一些代码。