public void subscribeInBackground ( final AVLiveQuerySubscribeCallback callback ) { Map < String , String > params = query . assembleParameters ( ) ; params . put ( "className" , query . getClassName ( ) ) ; Map < String , Object > dataMap = new HashMap <> ( ) ; dataMap . put ( QUERY , params ) ; String session = getSessionToken ( ) ; if ( ! StringUtil . isEmpty ( session ) ) { dataMap . put ( SESSION_TOKEN , session ) ; } dataMap . put ( SUBSCRIBE_ID , getSubscribeId ( ) ) ; RealtimeClient . getInstance ( ) . subscribeLiveQuery ( dataMap ) . subscribe ( new Observer < JSONObject > ( ) { @ Override public void onSubscribe ( Disposable disposable ) { } @ Override public void onNext ( JSONObject jsonObject ) { if ( null != jsonObject && jsonObject . containsKey ( QUERY_ID ) ) { queryId = jsonObject . getString ( QUERY_ID ) ; liveQuerySet . add ( AVLiveQuery . this ) ; loginLiveQuery ( callback ) ; } else if ( null != callback ) { callback . internalDone ( new AVException ( AVException . UNKNOWN , "response isn't recognized" ) ) ; } } @ Override public void onError ( Throwable throwable ) { if ( null != callback ) { callback . internalDone ( new AVException ( throwable ) ) ; } } @ Override public void onComplete ( ) { } } ) ; }
subscribe the query