作为原始类型成员对'continueWithTask....'的未经检查的调用



我在所有三种方法上都收到了这个警告,我试图在stackoverflow中搜索解决方案,但无法弄清楚可用的解决方案如何应用于我的情况。尽管代码工作正常,但代码块会以黄色突出显示,并且似乎一直在寻求关注。谢谢你的帮助!

final StorageReference storageReference = FirebaseStorage.getInstance().getReference()
.child(mStorageRef).child(mFileName);
final StorageTask storageTask = storageReference.putFile(intentDataUri);
storageTask.addOnProgressListener((OnProgressListener<UploadTask.TaskSnapshot>) taskSnapshot -> {
double p = 100.0 * taskSnapshot.getBytesTransferred() / taskSnapshot.getTotalByteCount();
progressDialog.setMessage((int) p + getString(R.string.percent_of) + taskSnapshot.getTotalByteCount() +getString(R.string.strUploading));
}).continueWithTask((Continuation) task -> {
if (!task.isSuccessful()) {
throw task.getException();
}
return storageReference.getDownloadUrl();
}).addOnCompleteListener((OnCompleteListener<Uri>) uriTask -> {

最终解决了这个问题,我修改了如下代码,它不再发出警告,用UploadTask替换了StorageTask,它起了作用-

final String messageID = databaseReference.child(getResources().getString(R.string.dbrefMessage)).child(mCurrentUserID)
.child(mMsgReceiverID).push().getKey();
final StorageReference storageReference = FirebaseStorage.getInstance().getReference()
.child(mStorageRef).child(mFileName);
final UploadTask uploadTask = storageReference.putFile(uri);
uploadTask.addOnProgressListener(taskSnapshot -> {
double p = 100.0 * taskSnapshot.getBytesTransferred() / taskSnapshot.getTotalByteCount();
progressDialog.setMessage((int) p + getString(R.string.percent_of) + taskSnapshot.getTotalByteCount() + getString(R.string.strUploading));
}).continueWithTask(task -> {
if(!task.isSuccessful()){
throw task.getException();
}
return storageReference.getDownloadUrl();
}).addOnCompleteListener(uriTask -> {

相关内容

  • 没有找到相关文章

最新更新