LiveConnectClient.BackgroundUploadAsync does not work when the phone is not connected to usb

I am trying to use LiveConnectClient.BackgroundUploadAsyncin wp8 to download a copy of some data.

This is my code:

var progress = new Progress<LiveOperationProgress>();
progress.ProgressChanged += progress_ProgressChanged;
try
{
   LiveOperationResult res = 
        await liveClient.BackgroundUploadAsync(folderID,
              new Uri(@"\shared\transfers\" + backupFile.Name, UriKind.Relative),
              OverwriteOption.Overwrite, new System.Threading.CancellationTokenSource().Token, progress);
   dynamic result = res.Result;
   fileID = result.id;
}
catch (Exception ex)
{
    System.Diagnostics.Debug.WriteLine(ex.Message);
    progress.ProgressChanged -= progress_ProgressChanged;
}

It works great on the emulator, but when I tried it on the phone, it worked only when the phone was connected to the computer via USB, the phone is connected to Wi-Fi.

+4
source share
1 answer

You encountered "problems" with the help of "Background Policies".

The operating system imposes a number of restrictions on background transfers related to file size, connection speed and device resources.

, / TransferPreferences - , 100 , , Wi-Fi .

WiFi downlod/upload, , () Wi-Fi .

:

// small files but via 3G and on Battery
liveClient.BackgroundTransferPreferences = BackgroundTransferPreferences.AllowCellularAndBattery;

// larger files via WiFi, on Battery
liveClient.BackgroundTransferPreferences = BackgroundTransferPreferences.AllowBattery;

// huge files but only WiFi and External power
liveClient.BackgroundTransferPreferences = BackgroundTransferPreferences.None;

- none - , , WiFi - , , USB ( ).

+4

Source: https://habr.com/ru/post/1531999/


All Articles