-1
我可以獲得已下載文件的百分比嗎?我在firebase.google.com上找不到與此相關的任何內容。如何從Firebase存儲下載時獲取百分比下載?
我可以獲得已下載文件的百分比嗎?我在firebase.google.com上找不到與此相關的任何內容。如何從Firebase存儲下載時獲取百分比下載?
使用此。
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());
}
}
感謝您的幫助! –
如果它是正確的,請將其標記爲答案,以便它可以幫助我的職業生涯。 –