-3
如何解決紅線的問題(taskSnapshots)如何解決紅線的問題(taskSnapshot)?
INT進度=(INT)((100.0 * taskSnapshot.getBytesTransferred())/ taskSnapshot.getTotalByteCount());
那條線有什麼問題?
private void uploadImg(final String path){
final Uri file = Uri.fromFile(new File(path));
StorageMetadata metadata = new StorageMetadata.Builder()
.setContentDisposition("universe")
.setContentType("image/jpg")
.build();
riversRef = mStorageRef.child(file.getLastPathSegment());
UploadTask uploadTask = riversRef.putFile(file, metadata);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
uploadInfoText.setText(exception.getMessage());
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
uploadInfoText.setText(R.string.upload_success);
Glide.with(NewPostActivity.this)
.load(file)
.into(downloadImg);
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
int progress = (int)((100.0 * taskSnapshot.getBytesTransferred())/taskSnapshot.getTotalByteCount());
imgUploadProgress.setProgress(progress);
if(progress >= 100){
imgUploadProgress.setVisibility(View.GONE);
}
}
});
}
檢查出會提供某些錯誤或建議。大部分在左上角的紅色燈泡。點擊它。即使再次錯誤沒有得到解決,然後谷歌。而谷歌無法提供解決方案,那麼很有可能你沒有按要求正確編寫程序,而且你還沒有意識到它。 –