0

I am having trouble getting the documentId for an added document. The add is working correctly, but the logs aren't posting and the documentId is returning null.

Here is what I have tried:

String rideKey = postRideInfo();


public String postRideInfo()
{

        HashMap map = new HashMap();
        map.put("customerId", userId);
        map.put("ended", false); 


        db.collection("ride_info").add(map).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
            @Override
            public void onSuccess(DocumentReference documentReference) {
                rideKey = documentReference.getId();
                Log.v(TAG,"Ride Key:"+rideKey);
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.v(TAG,"Add failed.",e.getCause());

            }
        });
return rideKey;
}

What am I missing?

Tai_
  • 19
  • 5

1 Answers1

0

I had it ridekey set to private and was accessing the class through another. I think that was the issue, because logs are now showing up. My own fault for not mentioning that. Noob mistake. Sorry. Hope this helps someone!

Tai_
  • 19
  • 5