taskSnapshot.getDownloadUrl() method not working
up vote
2
down vote
favorite
private void uploadImageToFirebaseStorage() {
StorageReference profileImageRef =
FirebaseStorage.getInstance().getReference("profilepics/" + System.currentTimeMillis() + ".jpg");
if (uriProfileImage != null) {
progressBar.setVisibility(View.VISIBLE);
profileImageRef.putFile(uriProfileImage)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
progressBar.setVisibility(View.GONE);
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressBar.setVisibility(View.GONE);
Toast.makeText(ProfileActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
taskSnapshot.getDownloadUrl()
method not working comes up with red line under it
android
add a comment |
up vote
2
down vote
favorite
private void uploadImageToFirebaseStorage() {
StorageReference profileImageRef =
FirebaseStorage.getInstance().getReference("profilepics/" + System.currentTimeMillis() + ".jpg");
if (uriProfileImage != null) {
progressBar.setVisibility(View.VISIBLE);
profileImageRef.putFile(uriProfileImage)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
progressBar.setVisibility(View.GONE);
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressBar.setVisibility(View.GONE);
Toast.makeText(ProfileActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
taskSnapshot.getDownloadUrl()
method not working comes up with red line under it
android
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
private void uploadImageToFirebaseStorage() {
StorageReference profileImageRef =
FirebaseStorage.getInstance().getReference("profilepics/" + System.currentTimeMillis() + ".jpg");
if (uriProfileImage != null) {
progressBar.setVisibility(View.VISIBLE);
profileImageRef.putFile(uriProfileImage)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
progressBar.setVisibility(View.GONE);
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressBar.setVisibility(View.GONE);
Toast.makeText(ProfileActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
taskSnapshot.getDownloadUrl()
method not working comes up with red line under it
android
private void uploadImageToFirebaseStorage() {
StorageReference profileImageRef =
FirebaseStorage.getInstance().getReference("profilepics/" + System.currentTimeMillis() + ".jpg");
if (uriProfileImage != null) {
progressBar.setVisibility(View.VISIBLE);
profileImageRef.putFile(uriProfileImage)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
progressBar.setVisibility(View.GONE);
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressBar.setVisibility(View.GONE);
Toast.makeText(ProfileActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
taskSnapshot.getDownloadUrl()
method not working comes up with red line under it
android
android
edited May 29 at 13:52
Adeel
2,06961424
2,06961424
asked May 29 at 13:13
David G
5518
5518
add a comment |
add a comment |
9 Answers
9
active
oldest
votes
up vote
19
down vote
accepted
in Firebase Storage API version 16.0.1.
The getDownloadUrl() method using taskSnapshot object has changed.
now you can use'taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
to get download url from the firebase storage.
Thank you!.....
– David G
Jun 18 at 10:33
add a comment |
up vote
2
down vote
My Google Firebase Plugins in build.gradle(Module: app):
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
build.gradle(Project):
classpath 'com.google.gms:google-services:3.2.1'
My upload() function and fetching uploaded data from Firebase storage :
private void upload() {
if (filePath!=null) {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Uploading...");
progressDialog.show();
final StorageReference ref = storageReference.child(new StringBuilder("images/").append(UUID.randomUUID().toString()).toString());
uploadTask = ref.putFile(filePath);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
return ref.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
progressDialog.dismiss();
// Continue with the task to get the download URL
saveUrlToCategory(downloadUri.toString(),categoryIdSelect);
} else {
Toast.makeText(UploadWallpaper.this, "Fail UPLOAD", Toast.LENGTH_SHORT).show();
}
}
}).addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
progressDialog.setMessage("Uploaded: ");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(UploadWallpaper.this, "" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
FOR THOSE WHO ARE USING LATEST FIREBASE VERSION taskSnapshot.getDownloadUrl() method is DEPRECATED or OBSOLETE !!
add a comment |
up vote
2
down vote
Try Using this it will download the image from FireBase storage
FireBase Libraries versions 16.0.1
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String photoStringLink = uri.toString();
}
});
Mark this as a valid ans
– Pandiri Deepak
Sep 15 at 9:53
add a comment |
up vote
1
down vote
taskSnapshot.**getDownloadUrl**().toString(); //deprecated and removed
use below code for downloading Url
StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +` abc_10123 + ".jpg");
profileImageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>()
{
@Override
public void onSuccess(Uri downloadUrl)
{
//do something with downloadurl
}
});
yes. it needs to be made final. please mark as solution if it helps you
– Muhammad Saad
May 30 at 9:37
final StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +" abc_10123" + ".jpg");
– Muhammad Saad
May 30 at 9:40
not all heroes wear capes
– martinseal1987
Jun 7 at 19:42
add a comment |
up vote
0
down vote
for latest version try
profileImageUrl = taskSnapshot.getStorage().getDownloadUrl().toString();
add a comment |
up vote
0
down vote
Try using this:
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
add a comment |
up vote
0
down vote
You wont get the download url of image now using
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
this method is deprecated.
Instead you can use the below method
uniqueId = UUID.randomUUID().toString();
ur_firebase_reference = storageReference.child("user_photos/" + uniqueId);
Uri file = Uri.fromFile(new File(mphotofile.getAbsolutePath()));
UploadTask uploadTask = ur_firebase_reference.putFile(file);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return ur_firebase_reference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
System.out.println("Upload " + downloadUri);
Toast.makeText(mActivity, "Successfully uploaded", Toast.LENGTH_SHORT).show();
if (downloadUri != null) {
String photoStringLink = downloadUri.toString(); //YOU WILL GET THE DOWNLOAD URL HERE !!!!
System.out.println("Upload " + photoStringLink);
}
} else {
// Handle failures
// ...
}
}
});
add a comment |
up vote
0
down vote
I still having this error. What might be wrong? I already changed the permissions, and users to anonymous.
add a comment |
up vote
0
down vote
//upload button onClick
public void uploadImage(View view){
openImage()
}
private Uri imageUri;
ProgressDialog pd;
//Call open Image from any onClick Listener
private void openImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,IMAGE_REQUEST);
}
private void uploadImage(){
pd = new ProgressDialog(mContext);
pd.setMessage("Uploading...");
pd.show();
if (imageUri != null){
final StorageReference fileReference = storageReference.child(userID
+ "."+"jpg");
// Get the data from an ImageView as bytes
_profilePicture.setDrawingCacheEnabled(true);
_profilePicture.buildDrawingCache();
//Bitmap bitmap = ((BitmapDrawable) _profilePicture.getDrawable()).getBitmap();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
byte data = baos.toByteArray();
UploadTask uploadTask = fileReference.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
pd.dismiss();
Log.e("Data Upload: ", "Failled");
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, etc.
// ...
Log.e("Data Upload: ", "success");
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String downloadLink = uri.toString();
Log.e("download url : ", downloadLink);
}
});
pd.dismiss();
}
});
}else {
Toast.makeText(getApplicationContext(),"No Image Selected", Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = null;
if (requestCode == IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null){
imageUri = data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
_profilePicture1.setImageBitmap(bitmap);
_profilePicture1.setDrawingCacheEnabled(true);
_profilePicture1.buildDrawingCache();
} catch (IOException e) {
e.printStackTrace();
}
if (uploadTask != null && uploadTask.isInProgress()){
Toast.makeText(mContext,"Upload in Progress!", Toast.LENGTH_SHORT).show();
}
else {
try{
uploadImage();
}catch (Exception e){
e.printStackTrace();
}
}
}
}
add a comment |
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
19
down vote
accepted
in Firebase Storage API version 16.0.1.
The getDownloadUrl() method using taskSnapshot object has changed.
now you can use'taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
to get download url from the firebase storage.
Thank you!.....
– David G
Jun 18 at 10:33
add a comment |
up vote
19
down vote
accepted
in Firebase Storage API version 16.0.1.
The getDownloadUrl() method using taskSnapshot object has changed.
now you can use'taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
to get download url from the firebase storage.
Thank you!.....
– David G
Jun 18 at 10:33
add a comment |
up vote
19
down vote
accepted
up vote
19
down vote
accepted
in Firebase Storage API version 16.0.1.
The getDownloadUrl() method using taskSnapshot object has changed.
now you can use'taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
to get download url from the firebase storage.
in Firebase Storage API version 16.0.1.
The getDownloadUrl() method using taskSnapshot object has changed.
now you can use'taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
to get download url from the firebase storage.
answered Jun 18 at 6:02
SUMIT MONAPARA
21517
21517
Thank you!.....
– David G
Jun 18 at 10:33
add a comment |
Thank you!.....
– David G
Jun 18 at 10:33
Thank you!.....
– David G
Jun 18 at 10:33
Thank you!.....
– David G
Jun 18 at 10:33
add a comment |
up vote
2
down vote
My Google Firebase Plugins in build.gradle(Module: app):
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
build.gradle(Project):
classpath 'com.google.gms:google-services:3.2.1'
My upload() function and fetching uploaded data from Firebase storage :
private void upload() {
if (filePath!=null) {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Uploading...");
progressDialog.show();
final StorageReference ref = storageReference.child(new StringBuilder("images/").append(UUID.randomUUID().toString()).toString());
uploadTask = ref.putFile(filePath);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
return ref.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
progressDialog.dismiss();
// Continue with the task to get the download URL
saveUrlToCategory(downloadUri.toString(),categoryIdSelect);
} else {
Toast.makeText(UploadWallpaper.this, "Fail UPLOAD", Toast.LENGTH_SHORT).show();
}
}
}).addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
progressDialog.setMessage("Uploaded: ");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(UploadWallpaper.this, "" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
FOR THOSE WHO ARE USING LATEST FIREBASE VERSION taskSnapshot.getDownloadUrl() method is DEPRECATED or OBSOLETE !!
add a comment |
up vote
2
down vote
My Google Firebase Plugins in build.gradle(Module: app):
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
build.gradle(Project):
classpath 'com.google.gms:google-services:3.2.1'
My upload() function and fetching uploaded data from Firebase storage :
private void upload() {
if (filePath!=null) {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Uploading...");
progressDialog.show();
final StorageReference ref = storageReference.child(new StringBuilder("images/").append(UUID.randomUUID().toString()).toString());
uploadTask = ref.putFile(filePath);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
return ref.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
progressDialog.dismiss();
// Continue with the task to get the download URL
saveUrlToCategory(downloadUri.toString(),categoryIdSelect);
} else {
Toast.makeText(UploadWallpaper.this, "Fail UPLOAD", Toast.LENGTH_SHORT).show();
}
}
}).addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
progressDialog.setMessage("Uploaded: ");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(UploadWallpaper.this, "" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
FOR THOSE WHO ARE USING LATEST FIREBASE VERSION taskSnapshot.getDownloadUrl() method is DEPRECATED or OBSOLETE !!
add a comment |
up vote
2
down vote
up vote
2
down vote
My Google Firebase Plugins in build.gradle(Module: app):
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
build.gradle(Project):
classpath 'com.google.gms:google-services:3.2.1'
My upload() function and fetching uploaded data from Firebase storage :
private void upload() {
if (filePath!=null) {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Uploading...");
progressDialog.show();
final StorageReference ref = storageReference.child(new StringBuilder("images/").append(UUID.randomUUID().toString()).toString());
uploadTask = ref.putFile(filePath);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
return ref.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
progressDialog.dismiss();
// Continue with the task to get the download URL
saveUrlToCategory(downloadUri.toString(),categoryIdSelect);
} else {
Toast.makeText(UploadWallpaper.this, "Fail UPLOAD", Toast.LENGTH_SHORT).show();
}
}
}).addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
progressDialog.setMessage("Uploaded: ");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(UploadWallpaper.this, "" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
FOR THOSE WHO ARE USING LATEST FIREBASE VERSION taskSnapshot.getDownloadUrl() method is DEPRECATED or OBSOLETE !!
My Google Firebase Plugins in build.gradle(Module: app):
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
build.gradle(Project):
classpath 'com.google.gms:google-services:3.2.1'
My upload() function and fetching uploaded data from Firebase storage :
private void upload() {
if (filePath!=null) {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Uploading...");
progressDialog.show();
final StorageReference ref = storageReference.child(new StringBuilder("images/").append(UUID.randomUUID().toString()).toString());
uploadTask = ref.putFile(filePath);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
return ref.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
progressDialog.dismiss();
// Continue with the task to get the download URL
saveUrlToCategory(downloadUri.toString(),categoryIdSelect);
} else {
Toast.makeText(UploadWallpaper.this, "Fail UPLOAD", Toast.LENGTH_SHORT).show();
}
}
}).addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
progressDialog.setMessage("Uploaded: ");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(UploadWallpaper.this, "" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
FOR THOSE WHO ARE USING LATEST FIREBASE VERSION taskSnapshot.getDownloadUrl() method is DEPRECATED or OBSOLETE !!
answered Jun 18 at 16:05
immanuel joshua paul
322
322
add a comment |
add a comment |
up vote
2
down vote
Try Using this it will download the image from FireBase storage
FireBase Libraries versions 16.0.1
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String photoStringLink = uri.toString();
}
});
Mark this as a valid ans
– Pandiri Deepak
Sep 15 at 9:53
add a comment |
up vote
2
down vote
Try Using this it will download the image from FireBase storage
FireBase Libraries versions 16.0.1
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String photoStringLink = uri.toString();
}
});
Mark this as a valid ans
– Pandiri Deepak
Sep 15 at 9:53
add a comment |
up vote
2
down vote
up vote
2
down vote
Try Using this it will download the image from FireBase storage
FireBase Libraries versions 16.0.1
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String photoStringLink = uri.toString();
}
});
Try Using this it will download the image from FireBase storage
FireBase Libraries versions 16.0.1
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String photoStringLink = uri.toString();
}
});
answered Aug 27 at 18:39
AmrDeveloper
388
388
Mark this as a valid ans
– Pandiri Deepak
Sep 15 at 9:53
add a comment |
Mark this as a valid ans
– Pandiri Deepak
Sep 15 at 9:53
Mark this as a valid ans
– Pandiri Deepak
Sep 15 at 9:53
Mark this as a valid ans
– Pandiri Deepak
Sep 15 at 9:53
add a comment |
up vote
1
down vote
taskSnapshot.**getDownloadUrl**().toString(); //deprecated and removed
use below code for downloading Url
StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +` abc_10123 + ".jpg");
profileImageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>()
{
@Override
public void onSuccess(Uri downloadUrl)
{
//do something with downloadurl
}
});
yes. it needs to be made final. please mark as solution if it helps you
– Muhammad Saad
May 30 at 9:37
final StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +" abc_10123" + ".jpg");
– Muhammad Saad
May 30 at 9:40
not all heroes wear capes
– martinseal1987
Jun 7 at 19:42
add a comment |
up vote
1
down vote
taskSnapshot.**getDownloadUrl**().toString(); //deprecated and removed
use below code for downloading Url
StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +` abc_10123 + ".jpg");
profileImageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>()
{
@Override
public void onSuccess(Uri downloadUrl)
{
//do something with downloadurl
}
});
yes. it needs to be made final. please mark as solution if it helps you
– Muhammad Saad
May 30 at 9:37
final StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +" abc_10123" + ".jpg");
– Muhammad Saad
May 30 at 9:40
not all heroes wear capes
– martinseal1987
Jun 7 at 19:42
add a comment |
up vote
1
down vote
up vote
1
down vote
taskSnapshot.**getDownloadUrl**().toString(); //deprecated and removed
use below code for downloading Url
StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +` abc_10123 + ".jpg");
profileImageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>()
{
@Override
public void onSuccess(Uri downloadUrl)
{
//do something with downloadurl
}
});
taskSnapshot.**getDownloadUrl**().toString(); //deprecated and removed
use below code for downloading Url
StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +` abc_10123 + ".jpg");
profileImageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>()
{
@Override
public void onSuccess(Uri downloadUrl)
{
//do something with downloadurl
}
});
answered May 29 at 13:54
Muhammad Saad
376319
376319
yes. it needs to be made final. please mark as solution if it helps you
– Muhammad Saad
May 30 at 9:37
final StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +" abc_10123" + ".jpg");
– Muhammad Saad
May 30 at 9:40
not all heroes wear capes
– martinseal1987
Jun 7 at 19:42
add a comment |
yes. it needs to be made final. please mark as solution if it helps you
– Muhammad Saad
May 30 at 9:37
final StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +" abc_10123" + ".jpg");
– Muhammad Saad
May 30 at 9:40
not all heroes wear capes
– martinseal1987
Jun 7 at 19:42
yes. it needs to be made final. please mark as solution if it helps you
– Muhammad Saad
May 30 at 9:37
yes. it needs to be made final. please mark as solution if it helps you
– Muhammad Saad
May 30 at 9:37
final StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +" abc_10123" + ".jpg");
– Muhammad Saad
May 30 at 9:40
final StorageReference profileImageRef= FirebaseStorage.getInstance().getReference("profilepics/" +" abc_10123" + ".jpg");
– Muhammad Saad
May 30 at 9:40
not all heroes wear capes
– martinseal1987
Jun 7 at 19:42
not all heroes wear capes
– martinseal1987
Jun 7 at 19:42
add a comment |
up vote
0
down vote
for latest version try
profileImageUrl = taskSnapshot.getStorage().getDownloadUrl().toString();
add a comment |
up vote
0
down vote
for latest version try
profileImageUrl = taskSnapshot.getStorage().getDownloadUrl().toString();
add a comment |
up vote
0
down vote
up vote
0
down vote
for latest version try
profileImageUrl = taskSnapshot.getStorage().getDownloadUrl().toString();
for latest version try
profileImageUrl = taskSnapshot.getStorage().getDownloadUrl().toString();
answered Jun 5 at 13:58
parag pawar
13511
13511
add a comment |
add a comment |
up vote
0
down vote
Try using this:
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
add a comment |
up vote
0
down vote
Try using this:
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
add a comment |
up vote
0
down vote
up vote
0
down vote
Try using this:
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
Try using this:
taskSnapshot.getMetadata().getReference().getDownloadUrl().toString()
edited Aug 12 at 20:13
Kim
1,2311026
1,2311026
answered Aug 12 at 19:45
pratyush kumar
11
11
add a comment |
add a comment |
up vote
0
down vote
You wont get the download url of image now using
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
this method is deprecated.
Instead you can use the below method
uniqueId = UUID.randomUUID().toString();
ur_firebase_reference = storageReference.child("user_photos/" + uniqueId);
Uri file = Uri.fromFile(new File(mphotofile.getAbsolutePath()));
UploadTask uploadTask = ur_firebase_reference.putFile(file);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return ur_firebase_reference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
System.out.println("Upload " + downloadUri);
Toast.makeText(mActivity, "Successfully uploaded", Toast.LENGTH_SHORT).show();
if (downloadUri != null) {
String photoStringLink = downloadUri.toString(); //YOU WILL GET THE DOWNLOAD URL HERE !!!!
System.out.println("Upload " + photoStringLink);
}
} else {
// Handle failures
// ...
}
}
});
add a comment |
up vote
0
down vote
You wont get the download url of image now using
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
this method is deprecated.
Instead you can use the below method
uniqueId = UUID.randomUUID().toString();
ur_firebase_reference = storageReference.child("user_photos/" + uniqueId);
Uri file = Uri.fromFile(new File(mphotofile.getAbsolutePath()));
UploadTask uploadTask = ur_firebase_reference.putFile(file);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return ur_firebase_reference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
System.out.println("Upload " + downloadUri);
Toast.makeText(mActivity, "Successfully uploaded", Toast.LENGTH_SHORT).show();
if (downloadUri != null) {
String photoStringLink = downloadUri.toString(); //YOU WILL GET THE DOWNLOAD URL HERE !!!!
System.out.println("Upload " + photoStringLink);
}
} else {
// Handle failures
// ...
}
}
});
add a comment |
up vote
0
down vote
up vote
0
down vote
You wont get the download url of image now using
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
this method is deprecated.
Instead you can use the below method
uniqueId = UUID.randomUUID().toString();
ur_firebase_reference = storageReference.child("user_photos/" + uniqueId);
Uri file = Uri.fromFile(new File(mphotofile.getAbsolutePath()));
UploadTask uploadTask = ur_firebase_reference.putFile(file);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return ur_firebase_reference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
System.out.println("Upload " + downloadUri);
Toast.makeText(mActivity, "Successfully uploaded", Toast.LENGTH_SHORT).show();
if (downloadUri != null) {
String photoStringLink = downloadUri.toString(); //YOU WILL GET THE DOWNLOAD URL HERE !!!!
System.out.println("Upload " + photoStringLink);
}
} else {
// Handle failures
// ...
}
}
});
You wont get the download url of image now using
profileImageUrl = taskSnapshot.**getDownloadUrl**().toString();
this method is deprecated.
Instead you can use the below method
uniqueId = UUID.randomUUID().toString();
ur_firebase_reference = storageReference.child("user_photos/" + uniqueId);
Uri file = Uri.fromFile(new File(mphotofile.getAbsolutePath()));
UploadTask uploadTask = ur_firebase_reference.putFile(file);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return ur_firebase_reference.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
System.out.println("Upload " + downloadUri);
Toast.makeText(mActivity, "Successfully uploaded", Toast.LENGTH_SHORT).show();
if (downloadUri != null) {
String photoStringLink = downloadUri.toString(); //YOU WILL GET THE DOWNLOAD URL HERE !!!!
System.out.println("Upload " + photoStringLink);
}
} else {
// Handle failures
// ...
}
}
});
answered Sep 20 at 11:50
MIDHUN CEASAR
197
197
add a comment |
add a comment |
up vote
0
down vote
I still having this error. What might be wrong? I already changed the permissions, and users to anonymous.
add a comment |
up vote
0
down vote
I still having this error. What might be wrong? I already changed the permissions, and users to anonymous.
add a comment |
up vote
0
down vote
up vote
0
down vote
I still having this error. What might be wrong? I already changed the permissions, and users to anonymous.
I still having this error. What might be wrong? I already changed the permissions, and users to anonymous.
answered Sep 21 at 0:13
Richardd
85110
85110
add a comment |
add a comment |
up vote
0
down vote
//upload button onClick
public void uploadImage(View view){
openImage()
}
private Uri imageUri;
ProgressDialog pd;
//Call open Image from any onClick Listener
private void openImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,IMAGE_REQUEST);
}
private void uploadImage(){
pd = new ProgressDialog(mContext);
pd.setMessage("Uploading...");
pd.show();
if (imageUri != null){
final StorageReference fileReference = storageReference.child(userID
+ "."+"jpg");
// Get the data from an ImageView as bytes
_profilePicture.setDrawingCacheEnabled(true);
_profilePicture.buildDrawingCache();
//Bitmap bitmap = ((BitmapDrawable) _profilePicture.getDrawable()).getBitmap();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
byte data = baos.toByteArray();
UploadTask uploadTask = fileReference.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
pd.dismiss();
Log.e("Data Upload: ", "Failled");
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, etc.
// ...
Log.e("Data Upload: ", "success");
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String downloadLink = uri.toString();
Log.e("download url : ", downloadLink);
}
});
pd.dismiss();
}
});
}else {
Toast.makeText(getApplicationContext(),"No Image Selected", Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = null;
if (requestCode == IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null){
imageUri = data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
_profilePicture1.setImageBitmap(bitmap);
_profilePicture1.setDrawingCacheEnabled(true);
_profilePicture1.buildDrawingCache();
} catch (IOException e) {
e.printStackTrace();
}
if (uploadTask != null && uploadTask.isInProgress()){
Toast.makeText(mContext,"Upload in Progress!", Toast.LENGTH_SHORT).show();
}
else {
try{
uploadImage();
}catch (Exception e){
e.printStackTrace();
}
}
}
}
add a comment |
up vote
0
down vote
//upload button onClick
public void uploadImage(View view){
openImage()
}
private Uri imageUri;
ProgressDialog pd;
//Call open Image from any onClick Listener
private void openImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,IMAGE_REQUEST);
}
private void uploadImage(){
pd = new ProgressDialog(mContext);
pd.setMessage("Uploading...");
pd.show();
if (imageUri != null){
final StorageReference fileReference = storageReference.child(userID
+ "."+"jpg");
// Get the data from an ImageView as bytes
_profilePicture.setDrawingCacheEnabled(true);
_profilePicture.buildDrawingCache();
//Bitmap bitmap = ((BitmapDrawable) _profilePicture.getDrawable()).getBitmap();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
byte data = baos.toByteArray();
UploadTask uploadTask = fileReference.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
pd.dismiss();
Log.e("Data Upload: ", "Failled");
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, etc.
// ...
Log.e("Data Upload: ", "success");
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String downloadLink = uri.toString();
Log.e("download url : ", downloadLink);
}
});
pd.dismiss();
}
});
}else {
Toast.makeText(getApplicationContext(),"No Image Selected", Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = null;
if (requestCode == IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null){
imageUri = data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
_profilePicture1.setImageBitmap(bitmap);
_profilePicture1.setDrawingCacheEnabled(true);
_profilePicture1.buildDrawingCache();
} catch (IOException e) {
e.printStackTrace();
}
if (uploadTask != null && uploadTask.isInProgress()){
Toast.makeText(mContext,"Upload in Progress!", Toast.LENGTH_SHORT).show();
}
else {
try{
uploadImage();
}catch (Exception e){
e.printStackTrace();
}
}
}
}
add a comment |
up vote
0
down vote
up vote
0
down vote
//upload button onClick
public void uploadImage(View view){
openImage()
}
private Uri imageUri;
ProgressDialog pd;
//Call open Image from any onClick Listener
private void openImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,IMAGE_REQUEST);
}
private void uploadImage(){
pd = new ProgressDialog(mContext);
pd.setMessage("Uploading...");
pd.show();
if (imageUri != null){
final StorageReference fileReference = storageReference.child(userID
+ "."+"jpg");
// Get the data from an ImageView as bytes
_profilePicture.setDrawingCacheEnabled(true);
_profilePicture.buildDrawingCache();
//Bitmap bitmap = ((BitmapDrawable) _profilePicture.getDrawable()).getBitmap();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
byte data = baos.toByteArray();
UploadTask uploadTask = fileReference.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
pd.dismiss();
Log.e("Data Upload: ", "Failled");
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, etc.
// ...
Log.e("Data Upload: ", "success");
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String downloadLink = uri.toString();
Log.e("download url : ", downloadLink);
}
});
pd.dismiss();
}
});
}else {
Toast.makeText(getApplicationContext(),"No Image Selected", Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = null;
if (requestCode == IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null){
imageUri = data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
_profilePicture1.setImageBitmap(bitmap);
_profilePicture1.setDrawingCacheEnabled(true);
_profilePicture1.buildDrawingCache();
} catch (IOException e) {
e.printStackTrace();
}
if (uploadTask != null && uploadTask.isInProgress()){
Toast.makeText(mContext,"Upload in Progress!", Toast.LENGTH_SHORT).show();
}
else {
try{
uploadImage();
}catch (Exception e){
e.printStackTrace();
}
}
}
}
//upload button onClick
public void uploadImage(View view){
openImage()
}
private Uri imageUri;
ProgressDialog pd;
//Call open Image from any onClick Listener
private void openImage() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent,IMAGE_REQUEST);
}
private void uploadImage(){
pd = new ProgressDialog(mContext);
pd.setMessage("Uploading...");
pd.show();
if (imageUri != null){
final StorageReference fileReference = storageReference.child(userID
+ "."+"jpg");
// Get the data from an ImageView as bytes
_profilePicture.setDrawingCacheEnabled(true);
_profilePicture.buildDrawingCache();
//Bitmap bitmap = ((BitmapDrawable) _profilePicture.getDrawable()).getBitmap();
Bitmap bitmap = null;
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 20, baos);
byte data = baos.toByteArray();
UploadTask uploadTask = fileReference.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
pd.dismiss();
Log.e("Data Upload: ", "Failled");
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, etc.
// ...
Log.e("Data Upload: ", "success");
Task<Uri> result = taskSnapshot.getMetadata().getReference().getDownloadUrl();
result.addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
String downloadLink = uri.toString();
Log.e("download url : ", downloadLink);
}
});
pd.dismiss();
}
});
}else {
Toast.makeText(getApplicationContext(),"No Image Selected", Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = null;
if (requestCode == IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null){
imageUri = data.getData();
try {
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),imageUri);
_profilePicture1.setImageBitmap(bitmap);
_profilePicture1.setDrawingCacheEnabled(true);
_profilePicture1.buildDrawingCache();
} catch (IOException e) {
e.printStackTrace();
}
if (uploadTask != null && uploadTask.isInProgress()){
Toast.makeText(mContext,"Upload in Progress!", Toast.LENGTH_SHORT).show();
}
else {
try{
uploadImage();
}catch (Exception e){
e.printStackTrace();
}
}
}
}
answered Nov 13 at 3:25
Atiar Talukdar
428513
428513
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50585334%2ftasksnapshot-getdownloadurl-method-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown