接收同步进度信息。
public SyncObserver
要在同步期间接收进度报告,您必须创建一个执行该任务的新类,并使用 setSyncObserver 函数实现此类。
下面的示例说明了一个简单的 SyncObserver 接口:
class MyObserver implements SyncObserver { public boolean syncProgress(int state, SyncResult result) { System.out.println( "sync progress state = " + state + " bytes sent = " + result.getSentByteCount() + " bytes received = " + result.getReceivedByteCount() ); return false; // Always continue synchronization. } public MyObserver() {} // The default constructor. } |
按如下方法启用上面的观察器类:
// J2ME Sample Connection conn; ConfigRecordStore config = DatabaseManager.createConfigurationRecordStore( "test.ulj" ); try { conn = DatabaseManager.connect(config); } catch(ULjException ex) { conn = DatabaseManager.createDatabase(config); // Create the schema here. } SyncParms.setSyncObserver(new MyObserver()); |
SyncObserver 的所有成员,包括所有继承的成员。
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |