Android Live query on a document not working

greetings!
I am trying to get real time changes on a document using the changelistener, however i have to refresh tha mobile app to see the change. Here is my gist https://gist.github.com/mikekaraa/89416ea8b074c71d7153

Please help me out if you have a solution

Hi @mikekara,

The document change listener should trigger when saving new revisions.

Can you share the code you have to register the change listener and update the document?

James

Hi @jamiltz, thank you for replying, I am using this code to read a value from the document in real time, I think my problem is how to use it to update the textview from within the changeListener

retrieve = database.getDocument(accou);
            Map<String, Object> properties = retrieve.getProperties();
            owner = (int) properties.get("account");
            Log.d(TAG, "doc "+owner);
            Titl.setText(String.valueOf(owner));
            retrieve.addChangeListener(new Document.ChangeListener() {
                @Override
                public void changed(Document.ChangeEvent event) {
                    DocumentChange docChange = event.getChange();
                    String msg = "New revision added: %s. Conflict: %s";
                    msg = String.format(msg,
                            docChange.getAddedRevision(), docChange.isConflict());
                    Log.d(TAG, msg);
 
                }
            });
            try {
                retrieve.createRevision().save();
            } catch (CouchbaseLiteException e) {
                e.printStackTrace();
            }
        }

Can you see the logs in the console?

For UI code in the change listeners, use the runUiThread block:

runOnUiThread(new Runnable() {
    @Override
    public void run() {
        // update text view's text
    }
});

Yes it worked!! Thank you so much @jamiltz, you are a life saviour!