0

i used firebase childEventListener in service class. Exactly what i had do in service class like this question code. The difference only that i used nested childEventListener

This nested childEventListener get data from child of child of unknown id. And service make sticky and this service is started by MainActivity (which is first visible activity).

Now the problem is When the MainActivity start the service , device got hanged until firebase is completely listen all data, and when listening is completed the device is working perfectly. Is there any solution for this lag produce by service class?

is it possible that nested childEventListener working on different thread, than please guide me Thank you

Ref.addChildEventListener(new ChildEventListener() {
        @Override
        public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
        {
            final String uid=dataSnapshot.getKey();
            Ref.child(uid).addChildEventListener(new ChildEventListener()
            {
                @Override
                public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
                {
                    Messages messages=dataSnapshot.getValue(Messages.class);
                    String pushKey=dataSnapshot.getKey();
                    if (!(pushKey ==null))
                    {
                        if(currentUid!=null)
                        { 
                            SomeMethods(messages,pushKey,myDbHandler,currentUid,uid);              
                        } 
                    }

                    @Override
                    public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s)
                    {
                        SomeMethods(messages,pushKey,myDbHandler,currentUid,uid);
                    }
Vora
  • 347
  • 2
  • 15

0 Answers0