I'm trying to create a simple application in UWP for a Zebra device (Model TC700J) running Windows 8, in which I make use of the built in barcode scanner.
From what I've found, there's plenty of Zebra tutorials for accessing the scanner when programming on Android, but none for Windows due to the fact that Microsoft provide their own generic barcode scanner API found in the Windows.Devices.PointOfService namespace.
The code I currently have looks something like this:
BarcodeScanner scanner;
ClaimedBarcodeScanner claimedScanner;
scanner = await BarcodeScanner.GetDefaultAsync();
if (scanner != null)
{
claimedScanner = await scanner.ClaimScannerAsync();
}
The problem is that the if statement never evaluates to true as the GetDefaultAsync method always returns null.
Over here there was an answer that seemed to work, stating that it depends where the GetDefaultAsync method is placed. I've tried to put it in all of the suggested places though and to no avail.
There is another method, BarcodeScanner.FromIdAsync() which returns a barcode based on the string representation of that barcode scanner's id sent as a parameter, but I'm not sure that'd be valid here as the barcode scanner is built into the device.
Looking at Zebra's site, TC700J seems to be model number of Windows 10 Mobile IoT Enterprize OS.
And the platform is ARM(Qualcomm snapdragon), not Intel x86/x64.
TC70 / TC75 Touch Computer Series
https://www.zebra.com/us/en/products/mobile-computers/handheld/tc7x-touch-computer-series.html
TC70x Operating System (TC700J) Windows 10 Mobile IoT Enterprise v1.13.02 Release Notes
https://www.zebra.com/us/en/support-downloads/software/release-notes/operating-system/tc70x-operating-system-v1-13-02--release-notes.html
For example, if your Zebra device is old hardware and Windows Phone 8/8.1 is running, Windows Phone does not seem to support Windows.Devices.PointOfService namespace.
It is described in the comment of the following article.
Windows Phone 8.1: Scan Barcodes using Camera
If your Zebra device can update to Windows 10 Mobile IoT Enterprise, please check it after doing it.
If you can update it, you can use the barcode scanner sample for Windows 10.
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BarcodeScanner
If your device is running on Windows 8 for x86, since Windows.Devices.PointOfService namespace is supported from Windows 8.1, you need to change the OS to Windows 8.1/10 if possible.
In that case you can use following, or above(for Windows10) sample.
Barcode scanner sample for Windows 8.1
https://code.msdn.microsoft.com/windowsapps/Barcode-scanner-sample-f39aa411
If you can not update it, please get the software and documentation for using BarcodeScanner from the vendor on Windows (Phone?) 8.
Seems the usage of Async method wasn't quite right.
Try below code:
BarcodeScanner scanner;
ClaimedBarcodeScanner claimedScanner;
scanner = await BarcodeScanner.GetDefaultAsync();
if (scanner != null)
{
claimedScanner = await scanner.ClaimScannerAsync();
}
More details:
https://learn.microsoft.com/en-us/dotnet/csharp/async
https://msdn.microsoft.com/en-us/magazine/jj991977.aspx?f=255&MSPPError=-2147217396
Related
I'm trying to develop winform(C#) application to search file from connected portable device(mobile device) using MTP.
I can get connected or disconnected status from wndproc method using WM_DEVICECHANGE.
But what I really want to develop is to cause an event when internal storage is created (it is able to read on window) after the deivce is connected from MTP.
So I was trying to create wndProc and input the code below in this code "if (m.Msg == UsbAlert.WM_DEVICECHANGE){ ... }"
if (devType == UsbAlert.DBT_DEVTUP_VOLUME)
{
Console.WriteLine("DBT DEVTUP VOLUME");
DEV_BROADCAST_VOLUME vol;
vol = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(m.LParam, typeof(DEV_BROADCAST_VOLUME));
Console.WriteLine(vol.dbcv_unitmask);
}
But it is only can operate portable device such as USB not a mobile phone (android, ios)
There are so many codes for connecting device to windows but not for mobile phone.
Please let me know how can set an event when internal storage is ready to scan on windows.
Can I use WndProc function to develop this or not.
Thank you.
I just solved by myself not using the WM_DEVTUP_VOLUME using wnd_proc fuctions.
This article make me solved the problem below.
How to get MTP device Available Storage & Storage Capacity using C#?
You can get storage voulme using WPD lib from windows.
Is there any way to know the game is running in an emulator application or a real device ?
Some Applications like VirtualXposed are virtual emulator for android devices. Such Applications allow users to install a game / application multiple times on their device with different identifies.
I want to know is there any way to recognize my game / application is running in emulator or a physical device in unity3d ?
something like :
if(isemulator)
{
dosomething();
}
It's not easy to do since there are many emulators out there. The answer from this post says that you can use Build.FINGERPRINT.contains("generic") to do that.
You can port the Java code to C# in Unity with the AndroidJavaClass class and without building Java plugin. Below is the ported version in C#:
public bool IsEmulator()
{
AndroidJavaClass osBuild;
osBuild = new AndroidJavaClass("android.os.Build");
string fingerPrint = osBuild.GetStatic<string>("FINGERPRINT");
return fingerPrint.Contains("generic");
}
To make sure that this covers most emulator, use the android-emulator-detector plugin. This plugin seems to be rigorously tested and detects most emulators. You can use AndroidJavaClass to communicate with it and UnityPlayer.UnitySendMessage to make callback into your Unity code in C#.
Maybe you can look for some emulator specific SystemInfos (Unity Docs SystemInfo) eg. SystemInfo.deviceModel
my app (developed in Windows Phone 8.1 RT environment) uses OpenFilePicker which allows me to choose image and capture an image, it works great however when I deployed this app on a Windows 10 device, this function just allowed me to pick an image from the library. I thought about a solution, writing a small code block which can help me to detect the version of the OS like this
#if WINDOWS_PHONE_APP
//codes
#endif
But I don't know exactly what I need to do, so please help me!
Read this link:
Windows Store Apps: Get OS Version, beginners tutorials (C#-XAML)
it purpose a simple solution to check is OS has Windows 10 features with reflection:
var analyticsInfoType = Type.GetType("Windows.System.Profile.AnalyticsInfo, Windows, ContentType=WindowsRuntime");
var versionInfoType = Type.GetType("Windows.System.Profile.AnalyticsVersionInfo, Windows, ContentType=WindowsRuntime");
if (analyticsInfoType == null || versionInfoType == null)
{
// That's not Windows 10
}
I have the following code working in Windows 7:
MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnInterfaceManager mbnInfMgrInterface = mbnInfMgr as IMbnInterfaceManager;
if (mbnInfMgrInterface != null)
{
IMbnInterface[] mobileInterfaces = mbnInfMgrInterface.GetInterfaces() as IMbnInterface[];
}
No problems when the MBN device exists but when an MBN device doesn't exist I get the following exception in the call to GetInterfaces():
{System.Runtime.InteropServices.COMException (0x80070490): Element not found. (Exception from HRESULT: 0x80070490)
at MbnApi.IMbnInterfaceManager.GetInterfaces()
at foo.Program.configureConnection() in foo}
Question
Is there something that should be done to check for a MBN interface before calling GetInterfaces? I can simply catch this exception but I can't find any documentation that says this exception is the same as having no interfaces.
The closest thing I have found on statckoverflow is this
struggling with mobile broadband api windows 7 and windows 8 with C#, not sure what to install
which implies that maybe windows 7 behaves differently than windows 8.1.
I got the same Element not found exception trying to use GetSignalStrength() and MbnInterfaceManager I instead found you can obtain a lot of useful info using WMI. Please see the answer here using SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface:
struggling with mobile broadband api windows 7 and windows 8 with C#, not sure what to install
UPDATE:
Please note that I found you cannot get the network info in Windows 8.1 in the same way as you do in Windows 7. See How can I install an application that requires WMI capabilities on Windows 8.1 to determine available bandwidth? and https://code.msdn.microsoft.com/windowsapps/network-information-sample-63aaa201
I recently installed the Windows Phone 8.1 emulators to try some existing apps out on them and ran into this problem: DeviceNetworkInformation.IsCellularDataEnabled (in the Microsoft.Phone.Net.NetworkInformation namespace) is always returning false.
public void UpdateDataEnabled()
{
_dataEnabled = DeviceNetworkInformation.IsCellularDataEnabled
|| DeviceNetworkInformation.IsWiFiEnabled;
}
I know the connection is actually working because I'm still able to perform HTTP requests. If I run this same exact code in the 8.0.x emulators I don't have any problems.
I also tried updating the project and all libraries to Windows Phone Silverlight 8.1 apps to see if that would resolve the issue and no luck. I checked all the capabilities and ID_CAP_NETWORKING was still checked as well.
The emulator is tested and working if I write a pure Windows Phone 8.1 XAML app using Windows 8 method of obtaining network status. It's just not working for my Silverlight apps.
I was under the impression that Windows Phone Silverlight apps should continue to function on Windows Phone 8.1 devices. Am I overlooking something?
I have the same problem and i did what verdesrobert and Rishabh876 suggested. Its only emulator problem so i add condition to check out if app is running on emulator
public bool IsNetworkAvailable()
{
if (DeviceNetworkInformation.IsNetworkAvailable)
{
if (Microsoft.Devices.Environment.DeviceType == DeviceType.Emulator)
{
return true;
}
else if ((DeviceNetworkInformation.IsWiFiEnabled || DeviceNetworkInformation.IsCellularDataEnabled) && NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None)
{
return true;
}
}
return false;
}
I dont like that workaround much so if anyone has better solution let me know.
It seems that the WP8.1 emulator is giving that information only to WP8.1 apps.
I'm pretty sure that the 7.1 apps will work properly on WP8.1 Devices.