Windows 10 UWP - How to check if Cellular data is enabled? - windows-10-universal

In Windows 10 UWP, how can I check if cellular data is enabled ?
I don't want to know what type is my current internet connection (NetworkInformation.GetInternetConnectionProfile()), I want to know if the cellular data radio is activated.
I think in Windows 8, we can do it using DeviceNetworkInformation.IsCellularDataEnabled, is there an equivalent for Windows 10 UWP ?
Thank you.

you can check this using NetworkInformation Class
https://msdn.microsoft.com/en-us/library/windows.networking.connectivity.networkinformation.getinternetconnectionprofile.aspx
ConnectionProfile networkProfile= NetworkInformation.GetInternetConnectionProfile();
if (networkProfile.IsWwanConnectionProfile)
{
WwanDataClass connection = networkProfile.WwanConnectionProfileDetails.GetCurrentDataClass();
}

I'm not sure if this will do exactly what you want, but I think you can try calling MobileBroabandAccount.AvailableNetworkAccountIds and select the first in range to get your default network account id. Then call MobileBroadbandAccount.CreateFromNetworkAccountId on that network account id and try using MobileBroadbandNetwork.NetworkRegistrationState on that network. See the MobileBroadbandNetwork documentation here and the possible fields here.
Here's my example:
Debug.WriteLine("Current network registration state is: " + MobileBroadbandAccount.CreateFromNetworkAccountId(MobileBroadbandAccount.AvailableNetworkAccountIds[0]).CurrentNetwork.NetworkRegistrationState);
I think that if your cellular data is disabled the result of this call will be Deregistered. I don't have a windows phone, but this is the case on my Windows desktop with a Mobile Broadband USB stick.
I know it's kinda of a work-around, but I'm not sure of any other way to just check if cellular data is enabled. Hope this helps in some way.
Edit
I did some more searching and found this similar thread here.
You should be able to use the answer there to solve your problem.

Related

Azure Kinect: how to find the windows device id

I have been developing a Win application that uses 3 Azure Kinects. Since there is no C# wrapper available yet, I made a C++ app that does what I need and the C# app just grabs its output files.
I now need to figure out which camera is which. In the C# app I can get the windows device id in a form similar to
\\.\USB#VID_045E&PID_097C#001007692912#{A5DCBF10-6530-11D2-901F-00C04FB951ED}
However the C API for the Kinect only provides ways to get the serial number of the device.
I tried to dig into the API, since I'm sure it must be somewhere in the code but, due to my limited C skills, I got lost pretty quickly.
Anybody with the same issue or can help?
Thanks,
Guido
The SDK is designed to use serial number specifically to determine which device or devices you are connected to. If you are just trying to use 2 Kinects with 2 instances of your C# then you will need to open devices until you find the serial number you are looking for. If you are trying to use multiple devices in a master/subordinate configuration then you can query for jack state to determine if you have connected to one or the other.
Also please be aware that we just released our own C# wrapper for the SDK. Checkout https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/608 and https://microsoft.github.io/Azure-Kinect-Sensor-SDK/master/namespace_microsoft_1_1_azure_1_1_kinect_1_1_sensor.html for more details.

access to phone's settings : codeName one

I would like to know if it's possible to access my phone settings using CodeNameOne. For example, if I want to get my EMEI( International Mobile Equiment Identity) or the serial number of my phone, is there a way to get it using codeNameOne?
If yes how ? if not, what alternative can I use?
thanks
We have Display.getMsisdn() & Display.getUdid() but those only work on Android and produce scary looking permission prompts.
Since this is Android specific it would make sense to code EMEI & similar calls with a native interface anyway.

Detect type of Display Device (Monitor/Projector) through Silverlight Client

I know that we can find the screen resolution of the client's monitor.
Is it possible to find out whether the type of device is Monitor or Projector?
If I want my web-based silverlight client to work only in Monitors and not on Projectors or vice versa, is it possible to enforce that?
The following SO question deals a similar matter in the case of java applets.
Detect Display Type (Projector) from within the browser
So whats the case with silverlight?
I don't think even Windows knows that. Most of the time it's the display driver and only on laptops. So, I don't know of any easy way of doing that. You could use encrypted DRM to enforce HDCP but even then...no go more than likely. Silverlight is basically VB .net or C# so perhaps try to find an example in those languages.
EDIT: I did some more looking around and found no real API that provided a way to detect an outputs type (Monitor or Projector)

Registering for USB insertion/removal notifications (Windows Service)

I am writing Windows Service which logs information on inserted or removed USB devices. RegisterDeviceNotification function returns valid handle, but SERVICE_CONTROL_DEVICEEVENT notifications still not come to service control handler function.
I used Tom Bell's "Detecting USB Device Insertion and Removal Using Windows API" and "Creating your own Windows Service" from Habrahabr.
I'm new to Services and Windows API, so could you please look at my code and tell what may be wrong? And if the code is correct, is there any pitfalls(?) connected with security restrictions or something like this?
[EDIT moved from answer]
The problem was not in code, but in incorrectly installed VirtualBox :)
The problem was not in code, but in incorrectly installed VirtualBox :)

How do you debug Share Picker extensions?

I have registered my Phone 7 app as a Share Picker Extension. It works—my app is in the list of Share options and it gets launched and I can load the chosen image. Okay, great.
But then things go wrong in my code. I would like to be able to debug the issues, but I can't seem to keep the debugger attached.
I cannot debug this in the simulator, since the Pictures app (and thus the Share Picker functionality) is not present in the simulator.
I cannot debug this on the phone because as soon as I pick my app from the Share list, the debugger detaches... right as my app is "launching" again.
Is it possible to attach the debugger to a running WP7 app? Is it possible to keep the debugger attached? Am I doing it wrong? Any suggestions, advice or guesses are welcome because I'm tearing my hair out.
When doing M+V hub integration (sorry, haven't done any pictures hub integration yet) I initially used a crude debug technique (Messagebox.Show, etc. - like Justin mentioned) to verify what was being passed to the NavigationEventArgs of OnNavigatedTo and wrapped the whole method in a try..catch block to learn what was going on. I then refactored the code when I knew what could be expected. (Remember OnNavigatedTo will be called when your app is launched normally too and so e won't be populated in the same way.)
When the app is launched from a/the hub it creates a new instance of the app and there is currently no way to connect to this for debugging while the main page is being navigated to.
Great question. I'm unsure if that's possible. As far as I know, there's no way to attach the debugger to when the WP7 O/S starts an app (which wasn't triggered by the debugger).
Photo Share picker extensibility, music+Video hub extensibility and other O/S extensibility points seem to not play nicely with the VS debugger. Normally I resort to MessageBox.Show to debug any problems with WP7 O/S integration.
1) Connect the Device
2) Turn off Zune
3) Start C:\Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\WPConnect\x86\WPConnect.exe
To properly debug your application that uses the Media Library, you'll need to use the Windows Phone Connect Tool (WPConnect.exe) as described on MSDN. Jaime has some additional tips on his blog.
Once you are connected, you should be able to debug your application. Fingers crossed anyway. If that doesn't help, I'll dig a bit further.
It's not so much about the WPConnect tool. The nature of your application means that you have to have it closed and the user should pick a photo. Only after that the data is returned to the application.
You should read about the application execution model on Windows Phone 7. Also a good explanation is available here.
Initially, I would say that you should look at tombstoning (a good explanation here) but then again, the image returned will re-start the app and won't allow you to directly attach the debugger.
Yeah, looks like this is impossible...
All the answers above seem to be missing the point: I presume you're able to debug your app in the "standalone" mode (when it's launched normally), but not when it's launched via the Share Picker Extension. Am I write? This is the wall I'm hitting... :-(
I thought the proper way would be to attach to the process once it's launched.
I tried to use Debug > Attach to Process, then select Smart Device as the Transport and Windows Phone Device as the Qualifier... But in return I get the ugly "Unable to connect to 'Windows Phone Device'. Not implemented" message.
Bummer :-(

Resources