Android - Firebase - TaskSnapshot - Method should only be accessed within private scope?
Solution 1:
The problem seems to be caused by an overzealous Lint check. Try something like this:
@SuppressWarnings("VisibleForTests") Uri downloadUrl = taskSnapshot.getDownloadUrl();
This trick worked for me. If the problem's related to this bug report, then it should be fixed in 2.4.
Solution 2:
I was stuck in the same issue and suppressWarnings didn't work for me. To get the complete download Uri i used the following code:
ref.putFile(imagePath).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
ref.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Log.d("URL", uri.toString());
// This is the complete uri, you can store it to realtime database
}
});
}
});
Hope this helps someone.