Windows.Networking.BackgroundTransfer.DownloadOperation is not working in Windows Phone 10 (but successfully works on Windows Phone 8.1) - windows-phone-8.1

I am writing Windows Phone 8.1 Silverlight application.
I am using DownloadOperation and UploadOperation from Windows.Networking.BackgroundTransfer namespace for downloading/uploading images, files...
And all work successfully on Windows Phone 8.1 devices/emulators, but not on Windows Phone 10 emulators.
The problem is that DownloadOperation / UploadOperation doesn't start downloading / uploading and not even giving progress callbacks or even an exception... It looks like that app begins sleeping after call .StartAsync()..
This is an example of how I am using this API:
StorageFile destinationFile;
try
{
destinationFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(item.Name,
CreationCollisionOption.ReplaceExisting);
}
catch (FileNotFoundException ex)
{
if (Debugger.IsAttached) Debugger.Break();
return;
}
var backgroundDownload = _backgroundDownloader.CreateDownload(new Uri(item.Url), destinationFile);
backgroundDownload.CostPolicy = BackgroundTransferCostPolicy.Always;
try
{
var progresscallback = new Progress<DownloadOperation>(operation =>
{
if (operation.Progress.TotalBytesToReceive != 0)
{
var progress = 100 * operation.Progress.BytesReceived / (double)operation.Progress.TotalBytesToReceive;
item.Progress = progress;
}
});
await backgroundDownload.StartAsync().AsTask(_cancellationTokenSource.Token, progresscallback);
var info = backgroundDownload.GetResponseInformation();
if (info.StatusCode == 200 || info.StatusCode == 206)
{
ImagesToDownload.Remove(item);
DownloadedImages.Insert(0, item);
}
else
{
if (Debugger.IsAttached) Debugger.Break();
}
}
catch (Exception ex)
{
if (Debugger.IsAttached) Debugger.Break();
}
}
I have seen that some other guys have the same problems:
BackgroundUploader and BackgroundDownloader in Windows 10 mobile
and
windows 10 apps DownloadOperation not starting
But I didn't find a solution how to resolve this problem? Cancelling of uncompleted operations and device restart doesn't help.
Help how to force to work DownloadOperation on Windows Phone 10 emulators/devices?
My small test Windows Phone 8.1 Silverligth app in which DownloadOperation works on Windows Phone 8.1 devices / emaulators, but not on Windows Phone 10 emulators
In this test app I can reproduce this bug even after first deployment of application when I am trying to download first 4 images...

Related

ZXing.Net.Mobile in Windows Phone 8.1

I am using ZXing.Net.Mobile in my windows phone 8.1 app. It is using below reference:
ZXing.Net.Mobile.Core
zxing.portable
ZXingNetMobile
My Code :
var scanner = new MobileBarcodeScanner();
MobileBarcodeScanningOptions options = new MobileBarcodeScanningOptions();
options.TryHarder = true;
options.PossibleFormats.Add(ZXing.BarcodeFormat.CODE_128);
options.PossibleFormats.Add(ZXing.BarcodeFormat.CODE_39);
var result = await scanner.Scan(options);
if (result != null)
{
MessageDialog a = new MessageDialog(result.Text);
a.Content = result.Text;
a.ShowAsync();
}
Issue:
Am getting below issue whenever scan method executes.
Use the platform specific implementations instead at ZXing.Mobile.MobileBarcodeScanner.Scan(....
Is there any real time QR code scanner available for windows phone 8.1 ?

App hangs while acquiring in-app product purchases

I'm developing a UWP app which has a single in-app purchase.
I've created in my Microsoft Developer account the in-app purchase and submitted it for review, which has been published in the Windows Store.
I've created the logic inside my app as follow:
private async Task CheckInAppPremium()
{
#if DEBUG
var file =
await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(#"Data\in-app.xml");
await CurrentAppSimulator.ReloadSimulatorAsync(file);
var licenseInformation = CurrentAppSimulator.LicenseInformation;
#else
var licenseInformation = CurrentApp.LicenseInformation;
#endif
if (!licenseInformation.ProductLicenses["Premium"].IsActive)
{
#if DEBUG
var results = await CurrentAppSimulator.RequestProductPurchaseAsync("Premium");
#else
var results = await CurrentApp.RequestProductPurchaseAsync("Premium");
#endif
Success = results.Status == ProductPurchaseStatus.Succeeded;
if (Success)
{
_localSettings.Values["premium"] = true;
Messenger.Default.Send(new PremiumInAppAcquiredMessage());
}
}
}
Everything works fine when app is running in DEBUG mode, but when the app is compiled in Release, the app hangs at this line:
var licenseInformation = CurrentApp.LicenseInformation;
I don't know what I missed, though I followed the Microsoft recommandations.

chrome app bluetooth api

I am trying to get the list of bluetooth devices paired with my windows 7 machine. I took the code from here https://developer.chrome.com/apps/app_bluetooth
var device_names = {};
var updateDeviceName = function(device) {
device_names[device.address] = device.name;
};
var removeDeviceName = function(device) {
delete device_names[device.address];
}
// Add listeners to receive newly found devices and updates
// to the previously known devices.
chrome.bluetooth.onDeviceAdded.addListener(updateDeviceName);
chrome.bluetooth.onDeviceChanged.addListener(updateDeviceName);
chrome.bluetooth.onDeviceRemoved.addListener(removeDeviceName);
// With the listeners in place, get the list of devices found in
// previous discovery sessions, or any currently active ones,
// along with paired devices.
chrome.bluetooth.getDevices(function(devices) {
for (var i = 0; i < devices.length; i++) {
updateDeviceName(devices[i]);
}
});
// Now begin the discovery process.
chrome.bluetooth.startDiscovery(function() {
// Stop discovery after 30 seconds.
setTimeout(function() {
chrome.bluetooth.stopDiscovery(function() {});
}, 30000);
});
In the manifest file i gave bluetooth permission
"bluetooth": {
"uuids": [ "1105", "1106" ]
}
But getDevices always return empty list even after startDiscovery is initiated.
I have enabled bluetooth in my mobile and paired it with my windows 7 as well even then its not showing the paired device when getdevice is called.
The chrome app is frameless and running in developer mode.
BTW my windows bluetooth UI shows my mobile device and some other devices as well
I will be grateful if anyone can suggest where i am making a mistake?

Windows Phone 8.1 AppBarButton with custom BitmapIcon

I want to create a custom image for the AppbarButton.
I'm using code from
Windows Phone 8.1 AppBarButton icon with 2 rows of text
RenderTargetBitmap rtb = new RenderTargetBitmap();
await rtb.RenderAsync(TodayTextBorder);
IBuffer pixels = await rtb.GetPixelsAsync();
string filename = "TodayIcon.png";
var outputFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename, Windows.Storage.CreationCollisionOption.ReplaceExisting);
using (var outputStream = await outputFile.OpenAsync(FileAccessMode.ReadWrite))
{
BitmapEncoder enc = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, outputStream);
var dpi = DisplayInformation.GetForCurrentView().LogicalDpi;
enc.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)rtb.PixelWidth, (uint)rtb.PixelHeight, dpi, dpi, pixels.ToArray());
await enc.FlushAsync();
}
BitmapIcon icon = new BitmapIcon();
icon.UriSource = new Uri("ms-appdata:///local/" + filename);
TodayAppbarButton.Icon = icon;
But it doesn't work. Well, it works on the Emulator and on the phone in case the app was deployed directly from Visual Studio. But when I'm publishing app and installing it from the Store I'm getting erroneous appbar button image (like this http://i.imgur.com/de73cTo.png)

Choose default webcam for node-webkit

I have a node-webkit application that is using RecordRTC to capture a snippet of video. I'm running the application on a Windows Surface Pro 3, and need the front-facing webcam to be used instead of the back-facing one. I know there is a setting in Chrome to change the default webcam, but how do I configure this in node-webkit?
I don't have a device to test this on but it should work. I believe mobile devices will return either 'user' or 'environment' to determine if it's front or rear facing.
var devices = function (devices) {
for (var i = 0; i !== devices.length; ++i) {
var camera = devices[i];
if (camera.kind === 'video' && camera.facing === 'user') {
createStream(camera.id);
} else {
console.log('No front facing camera');
}
}
}
var createStream = function(id) {
var settings = {video: {optional: {sourceId: id} }};
navigator.webkitGetUserMedia(settings, successCallback, errorCallback);
};
MediaStreamTrack.getSources(devices);
This basically loops through all of the available devices and checks if it's a video source and that it is facing the user. It will then use the id of that device to create the media stream.