Passing firebase data by intent causes java.lang.IllegalArgumentException

Viewed 92

My data is from Firebase cloud Firestore, it doesn't contain a slash "/" because every solution to this problem about this always tell me to use .replace("/","-"). The ID is a generic ID from Firebase "cHkncpz6RVHv4ITFlICr"

HomePageAdapter.java

Intent passID = new Intent(itemView.getContext(),Destination.class);
passID.putExtra("ID", destinationID);
itemView.getContext().startActivity(passID);

Destination.java

ID = getIntent().getStringExtra("ID");
firebaseFirestore.collection("DESTINATION").document(ID) <----- this line throws java.lang.IllegalArgumentException: Invalid document reference. Document references must have an even number of segments, but DESTINATIONS has 1

What I tried so far are:

  1. Replacing the String ID into ID = "cHkncpz6RVHv4ITFlICr"; and of course the app works.
  2. Tracked if the ID is blank, it was not because the LOG says the ID is "cHkncpz6RVHv4ITFlICr".
Log.d("ID", destinationID);

returns

D/ID: cHkncpz6RVHv4ITFlICr
  1. Replaced the extra in Intent passID.putExtra("ID", "cHkncpz6RVHv4ITFlICr"); the app didn't work.

So what I conclude is the intent is causing this exception. Any help is much appreciated.

0 Answers
Related