When I run this method returns V = null
, In consideration V inside onComplete(...
, its not null
public static Vehicle v;
public static Vehicle tessst() {
v = new Vehicle();
DocumentReference docRef = db.collection("vehicles").document("123");
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if(task.isSuccessful()){
DocumentSnapshot documentSnapshot = task.getResult();
if(documentSnapshot !=null){
v = documentSnapshot.toObject(Vehicle.class);
}
}
}
});
return v;
}