I have a MySql central database syncing with a number of android clients
over the web - a change in any client propates to all the others. So far so
good.
What I can't figure out now is when to update the client displays - i.e. I
don't know when the underlying client sqlite database has changed. It seems
rather ugly to update the client display from the database on a timer. What
is needed is some sort of OnChanged event - is there such?
You could use the ILoadSyncLifecycleListener, but you need access to the AndroidSymmetricEngine to register yourself as a listener. It would look like this:
androidSymmetricEngine.getDataLoaderService().addLoadSyncLifecycleListener(
new ILoadSyncLifecycleListener() {
public void syncStarted(DataContext context) {
}
public void syncEnded(DataContext context,
List<IncomingBatch> batchesProcessed, Throwable ex) {
}
});
Your application code to run SymmetricDS probably has a line like this:
Intent intent = new Intent(getContext(), SymmetricService.class);
I think you'd need to replace SymmetricService with your own class that gives you access to the AndroidSymmetricEngine that it creates. There is an issue in the tracker to make this API better for callbacks, but that's what you have to do for now.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a MySql central database syncing with a number of android clients
over the web - a change in any client propates to all the others. So far so
good.
What I can't figure out now is when to update the client displays - i.e. I
don't know when the underlying client sqlite database has changed. It seems
rather ugly to update the client display from the database on a timer. What
is needed is some sort of OnChanged event - is there such?
Regards
Peter
Regards
Peter
My PGP public key is available at http://pgp.mit.edu Key number 87ED3230
https://pgp.mit.edu/pks/lookup?op=get&search=0x4678CD6787ED3230
You could use the ILoadSyncLifecycleListener, but you need access to the AndroidSymmetricEngine to register yourself as a listener. It would look like this:
androidSymmetricEngine.getDataLoaderService().addLoadSyncLifecycleListener(
new ILoadSyncLifecycleListener() {
public void syncStarted(DataContext context) {
}
});
Your application code to run SymmetricDS probably has a line like this:
Intent intent = new Intent(getContext(), SymmetricService.class);
I think you'd need to replace SymmetricService with your own class that gives you access to the AndroidSymmetricEngine that it creates. There is an issue in the tracker to make this API better for callbacks, but that's what you have to do for now.