Open Locations Toggle in Windows Phone 7 - c#

I like to know how to open location toogle in c#, for example for wifi i use this:
ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
connectionSettingsTask.Show();
I like a stuff like that but for location.

Though, in Windows Phone 8, this can be done using
Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-location:"))

There is no task to do this for you - each app that uses the location sensors is expected to have this setting in their own settings page.

Related

Is it possible to launch system/third party app using an NDEFLaunchApp record to get the URI and by using LaunchUriAsync without NFC Tags?

So I have spent the whole night looking like a zombie in the morning trying to figure out how the OS handles an NFC tap for an NDEFLaunchApp Record and I have known the following.
I'm pretty sure that there is a workaround which lets you launch a system app / third party app (if you know the product Id / GUID) from your app. As there are apps in the Windows Phone Store which I have somehow figured out what I've been trying to.
I have come up with the following code:
NdefLaunchAppRecord appLaunchRecord = new NdefLaunchAppRecord();
appLaunchRecord.AddPlatformAppId("WindowsPhone", "{App GUID}");
appLaunchRecord.Arguments = "_default";
// Creating a new NdefMessage from the above record.
var message = new NdefMessage { appLaunchRecord };
// Getting the record from the message that we just created
foreach (NdefLaunchAppRecord record in message)
{
var specializedType = record.CheckSpecializedType(false);
if (specializedType == typeof(NdefLaunchAppRecord))
{
var x = String.Join(" ", record.Payload);
// Getting the payload by GetString gets a formatted Uri with args
string result = System.Text.Encoding.UTF8.GetString(record.Payload, 0, record.Payload.Length);
// result = "\0\fWindowsPhone&{5B04B775-356B-4AA0-AAF8-6491FFEA5630}\0\b_default";
// result = "(null)(form feed)WindowsPhone&{App GUID}(null)(backspace)_default
// So this will be sent to the OS and I believe the OS will then launch the specified app by an unknown protocol
// like xxx://result
// and the app will be launched?
// So is it then possible to somehow call the following:
await Windows.System.Launcher.LaunchUriAsync(new Uri("OUR MAGIC RESULT?", UriKind.RelativeOrAbsolute));
If anyone has / can figure out a way for this, it would be a REAL Service to the WP Community as developers are restricted by Microsoft to open certain settings / apps which are actually needed by those apps. For instance (speech settings, audio settings, about settings, alarms, region settings, date+time);
APPS that possibly have a workaround:
Music Hub Tile (Launches the old Music+Videos Hub)
http://www.windowsphone.com/en-gb/store/app/music-hub-tile/3faa2f9e-6b8d-440a-bb60-5dd76a5baec1
Tile for Bing Vision
http://www.windowsphone.com/en-gb/store/app/tile-for-bing-vision/05894022-e18c-40a4-a6cc-992383aa7ee8
There are reserved uri schemes for bing and zune.
See: http://msdn.microsoft.com/en-us/library/windows/apps/jj207065(v=vs.105).aspx
Those two apps propably use these and have found some undocumented use of the scheme.
If there is an uri scheme that launches any app by guid from within your app, it is hidden well.
Currently you can only launch apps that registered for an uri scheme or file association.

Windows phone 8.1 Geo Location does not work unless the phone resides in the geo-location for atleast 2 to 3 seconds

I am creating a windows Phone 8.1 application with the Geo Location. The code works, well pretty much, the one thing that I have noticed in the simulator, if the phone does not reside in the Geo-Fenced area for a 2 .. 3 .. seconds the background code does not fire even though I create my dwell time with no parameters.
MonitoredGeofenceStates mask = 0;
mask |= MonitoredGeofenceStates.Entered;
var geocircle = new Geocircle(position, 100);
gFence = new Geofence(ID, geocircle, mask, false);
I found the following blog but it was not that useful
http://blogs.windows.com/buildingapps/2014/02/25/testing-and-debugging-your-geofencing-apps/
How often does a phone or device check if its in a Geo fenced area? I would like to tell my users for their geo-fence to be active they must reside in the geo-fenced area for a minimum of x seconds...

Using PowerStatus class in windows phone 7 app

I am new to windows phone app development.
I am trying to use the powerStatus class in a windows phone 7 app. I have searched quite a bit regarding that and learnt that it is necessary to add reference of System.Windows.Forms
But in the add reference of the project 'System.Windows.Forms' is not present.
How can I use the powerStatus class?
Please help.
Thank you.
Please Refer this msdn link that will clearly shows that how can you get the status of the Battery. i.e. The remaining Percentage of charge in phone;s battery.
Know the battery status in windows phone
In this link, use the RemainingChargePercent() Method this will return the value that indicates the percentage of the charge remaining on the phone's battery.
This things will used in windows phone 8 only.
But, you are with windows phone 7. so, currently there is no API available for windows phone 7 to know the remaining charge in phone's battery.
You will get the information like the if your phone is connected to power source or running in battery.
I will show here some important msdn question links that shows that there is no method or the class is available to get the charge level in windows phone 7.
The MSDN Question link: how to get the battery status in windows phone 7.
if you have the need to show the battery charge percentage, then i suggest you to proceed with windows phone 8.
It work for wp8. but I am not sure about wp7.
_battery = Battery.GetDefault();
var remainingCharge = string.Format("{0} %", _battery.RemainingChargePercent);
var remainingTime = _battery.RemainingDischargeTime.TotalMinutes;
_battery.RemainingChargePercentChanged += OnRemainingChargePercentChanged;
private void OnRemainingChargePercentChanged(object sender, object e)
{
var remainingCharge = string.Format("{0} %", _battery.RemainingChargePercent);
var remainingTime = _battery.RemainingDischargeTime.TotalMinutes;
if(Microsoft.Phone.Info.DeviceStatus.PowerSource == Microsoft.Phone.Info.PowerSource.External)
var text = "Charger Connected";
else
var text = "Charger Not Connected";
}

Get system locale in Windows 8 Metro app

in Windows 8 C# WindowsStore app if I call
System.Globalization.RegionInfo.CurrentRegion
I get US, although in Control Panel - Region I have location and language = UK...
How do I get country of the device NOT using geolocation?
var region = new Windows.Globalization.GeographicRegion();
Parameterless constructor of GeographicRegion sreates a GeographicRegion object that defaults to the user's home region.

How to end Periodic Updates to a Windows 8 Live Tile

I've seen lots of examples of how to begin Periodic Updates to a live tile in Windows 8, e.g:
PeriodicUpdateRecurrence recurrence = PeriodicUpdateRecurrence.Hour;
System.Uri url = new System.Uri(polledUrl);
TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdate(url, recurrence);
However, how do you undo this? I've added an app setting to disable the live tile updates but I can't find code to remove the polling.
I discovered the answer by browsing through the Intellisense options.
To revert a tile to its default state, i.e. not live, use:
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
Hope this helps someone - it wasn't easy to find in any of the Windows Dev Centre Quickstarts.
PeriodicUpdateRecurrence recurrence = PeriodicUpdateRecurrence.Hour;
System.Uri url = new System.Uri(polledUrl);
var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
tileUpdater.StartPeriodicUpdate(url, recurrence);
// ...
tileUpdater.StopPeriodicUpdate();

Categories