编译应用程序时出现错误。它说
task.getResult()。getDownloadUrl()。toString()找不到符号
filePath.putFile(fileUri).addOnCompleteListener(task -> {
if (task.isSuccessful()){
Map messageTextBody = new HashMap();
messageTextBody.put("message", task.getResult().getDownloadUrl().toString());
messageTextBody.put("name", fileUri.getLastPathSegment());
messageTextBody.put("type", checker);
messageTextBody.put("from", messageSenderID);
messageTextBody.put("to", messageReceiverID);
messageTextBody.put("messageID", messagePushID);
messageTextBody.put("time", saveCurrentTime);
messageTextBody.put("date", saveCurrentDate);
Map messageBodyDetails = new HashMap();
messageBodyDetails.put(messageSenderRef + "/" + messagePushID, messageTextBody);
messageBodyDetails.put(messageReceiverRef + "/" + messagePushID, messageTextBody);
RootRef.updateChildren(messageBodyDetails);
loadingBar.dismiss();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
loadingBar.dismiss();
Toast.makeText(ChatActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
double p = (100.0*taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
loadingBar.setMessage((int) p + " % Uploading...");
}
});
答案 0 :(得分:0)
问题是
task.getResult().getDownloadUrl().toString());
替换为
task.getResult().toString();