Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在从Firebase存储下载时获得下载百分比?_Android_Firebase_Firebase Storage - Fatal编程技术网

Android 如何在从Firebase存储下载时获得下载百分比?

Android 如何在从Firebase存储下载时获得下载百分比?,android,firebase,firebase-storage,Android,Firebase,Firebase Storage,我可以获得已下载文件的百分比吗?我在firebase.google.com上找不到任何与此相关的内容。使用此功能 public void onProgress(FileDownloadTask.Task task) { double fprogress = (100.0 * task.getBytesTransferred()) / task.getTotalByteCount(); int bytes = task.getBytesTransferred(); String progress

我可以获得已下载文件的百分比吗?我在firebase.google.com上找不到任何与此相关的内容。

使用此功能

public void onProgress(FileDownloadTask.Task task) {
double fprogress = (100.0 * task.getBytesTransferred()) / task.getTotalByteCount();
int bytes = task.getBytesTransferred();

String progress = String.format("%.2f", fprogress);
int constant = 1000;
if(bytes%constant == 0)
{
NotificationCompat.Builder mBuilder = 
    new NotificationCompat.Builder(getApplicationContext())
    .setSmallIcon(android.R.drawable.stat_sys_download)
    .setContentTitle("Downloading " + model.getName())
    .setContentText(" " + progress + "% completed" );

NotificationManager mNotificationManager = 
   (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

mNotificationManager.notify(mId, mBuilder.build());
}

}

谢谢你的帮助,伙计!如果答案正确,请将其标记为答案,以便对我的职业生涯有所帮助。