I was able to make the application stay listener more how do I do data 
synchronization after that? I need to push the listener


    try {
        manager = new Manager(new AndroidContext(getApplicationContext()), 
Manager.DEFAULT_OPTIONS);
    } catch (IOException e) {
        e.printStackTrace();
    }
    database = DatabaseHelper.getEmptyDatabase("bancsdqs32", manager);
    startListener();
    startObserveDatabaseChange();

    URL url = null;
    try {
        url = new URL("http", getLocalIpAddress(), listener.getListenPort(), 
"/bancsdqs32");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    System.out.println("Listening on :: " + listener.getListenPort() + " " + 
url.toString());

}

public String getLocalIpAddress() {
    WifiManager wm = (WifiManager) 
getApplicationContext().getSystemService(WIFI_SERVICE);
    return Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
}

void startObserveDatabaseChange() {
    try {
        database.addChangeListener(new Database.ChangeListener() {
            @Override
            public void changed(Database.ChangeEvent event) {
                List<DocumentChange> changes = event.getChanges();
                System.out.println("erroooo" +
                        changes);

                for (DocumentChange change : changes) {
                    System.out.println("erroooo " + change.getDocumentId());

                }
            }
        });
    } catch (Exception e) {
        System.out.println("erro " + e);
    }
}

void startListener() {
    listener = new LiteListener(manager, 5432, null);
    Thread thread = new Thread(listener);
    thread.start();
}


-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/5d98e2ea-b515-4104-83e1-a67f383963ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to