how to know if firebase ChildEventListener found child ? [android]
<p>so I'm trying to get users key by their email and the problem is that I dont know inside my code if the query actually found something or not .. so I'm assuming if I'm inside onchildadded that the query is successful and a child has been found so I will pass the key to another activity and stop current activity but when I run the app the whole code get executed .. I feel my way is kinda wrong but I didn't find any way to know if the query is sucsessful or a child is found .... if you have any idea pleas help ...</p>

<pre><code>  public void searchemail(String email){

  Firebase ref = new Firebase("https://&lt;myfirebase&gt;.firebaseio.com/users");
    Query queryRef = ref.orderByChild("Email").equalTo(email);


     ChildEventListener listener = new ChildEventListener() {

        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s) {

            userkey = dataSnapshot.getKey();
              homeintent.putExtra("key", userkey);
               startActivity(homeintent);
               finish();
               return; 
                 // I want code to stop here 

        }}
    queryRef.addChildEventListener(listener);

      Toast toast = Toast.makeText(this, "email not found", Toast.LENGTH_SHORT); // Im assuming if Im here then no child is found but this always get executed before startactivity  
   }
</code></pre>

<p>OUTPUT :
if email found -> toast will show then home activity will start...
if email not found -> only toast will show..</p>