Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------------
        public async void StartDownloadHandlerAndroid(object sender, System.EventArgs e)
        {
            //_progressBar.Progress = 0;
            currentProgress = 0;



            Progress <DownloadBytesProgress> progressReporter = new Progress <DownloadBytesProgress>();

            progressReporter.ProgressChanged += (s, args) => {
                currentProgress = (int)(100 * args.PercentComplete);  // _progressBar.Progress = (int)(100 * args.PercentComplete);
                result.Text     = currentProgress.ToString();
                if (progressBar.Width != currentProgress)
                {
                    progressBar.WidthRequest = currentProgress;
                }
            };

            Task <int> downloadTask    = DownloadFile.CreateDownloadTask(DownloadFile.FileURLToDownload, localFolder, localFileName, progressReporter);
            int        bytesDownloaded = await downloadTask;

            System.Diagnostics.Debug.WriteLine("Downloaded {0} bytes.", bytesDownloaded);

            ReadFile(localFolder, localFileName);
        }