I have UWP application and I want to retrieve the Power and Sleep setting information and display it to the UI.
For example:
On Windows settings, I set the Sleep timer to Never
Then when I open my UWP application and go to Power setting UI,
it will reflect the selected settings in the dropdown list.
My question now is, Is it possible to control (Read, Update) the Power and Sleep setting in Windows 10 thru C# programming. If yes, Any Tips on how to Achieve this feature in my App that I can Change and Display the Sleep settings to the application UI.
Any suggestion or comments are appreciated.
I can not find any api to change it but you can send the user to setting page to set the power.
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:powersleep"));
If you want your app run without off screen like a video app that you can use this code.
var displayRequest = new DisplayRequest();
displayRequest.RequestRelease();
See: Launch the Windows Settings app - UWP app developer
Related
I have an app that needs to create a pop up to notify the user of something, even when the app is closed. I would like it to be fullscreen, but if that's not possible, a pop up that takes up most of the screen will do. I don't know how to make part of the app run in the background on Android and iOS to check if it's time for the pop up. I also don't know how to go about making the actual pop up. Any help would be greatly appreciated!
Side notes: I am using a cross platform Xamarin.Forms app. I have a main page that the user can set the time they want the pop up to appear, and I save this to the Application.Current.Properties dictionary for data persistence.
Background tasks on mobile has quite a lot of limitations. Which is logical. The user would not like if some app will always run in background and collect user data, drain the battery or affect overal performance of the the mobile device. Therefore for there are strict set of rules every developer must follow when creating a background tasks.
You best bet would be to use local notifications, there is a well documented open source library that you can use for this. There will be no pop-ups but notifications which you could customize according to OS guides.
I would like to use the LaunchUriForResultAsync to launch my other app and get some results from it. But I want to launch the other app in full screen and if that's not possible maybe just launch it in a bigger size.
When I launch another app using LaunchUriForResultAsync, the modal app launches in 500x500 size. I would need something bigger than that because I need to create a data entry app that requires more space which multiple applications can launch. I tried to set the DesiredRemainingView and PreferredLaunchWindowingMode to FullScreen. It didn't make my other app launch in full screen.
Is there a way I can use LaunchUriForResultAsync to launch my other app in full screen?
If the device is in Tablet Mode, you can use ViewSizePreference.SizeNone and the app will be launched in full screen:
var options = new Windows.System.LauncherOptions();
options.DesiredRemainingView = Windows.UI.ViewManagement.ViewSizePreference.UseNone;
await Windows.System.Launcher.LaunchUriAsync(uri, options);
I think part of the confusion here is that the size preference defines the space your current app desires, not the size you want for the launched app. Because the target app can have its own preferences.
This solution does not work if Tablet Mode is disabled, then you would have to go with a solution as Rob Caplan suggested.
It is not possible to control the size of the window launched for results. In current versions of Windows this size is hard coded to 500x500. Providing a way to allow an app to control this is being investigated for future a future update.
Since you control both apps you could write a custom system to manage the communication rather than use LaunchUriForResultAsync. AppA and AppB can each define their own protocols (appa: and appb:). AppA can LaunchUriAsync appb: to do whatever it needs, then AppB can LaunchUriAsync appa: to deliver the results. Pass AppA's return URL as an argument to appb: and this can be called from multiple apps.
The trickiest part may be to manage the modality. It's easy to disable AppA's page while it's waiting, but harder to link AppB's window to AppA's after the initial launch. Off the top of my head I'd just relaunch appb: and make sure appb: can track and handle multiple launches sanely.
This is more or less what LaunchUriForResultAsync does for you.
I am designing a Windows 10 Universal application using this https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Printing/cs repository as a guide. I currently have fully functional printing by calling:
await Printmanager.ShowPrintUIAsync();
In my application there is also an activity timer that logs the user out after a certain amount of time inactive. This part is working fine, but I am unable to close the print ui upon logout.
Note: Normally to close a windows async operations, you can do something similar to:
IAsyncOperation<bool> printOperation = Printmanager.ShowPrintUIAsync();
printOperation.Cancel();
This works for other AsyncOperation occurences, but I cannot get it to work for the print UI, as the print UI is not a child process of the app, but is a seperate process itself
Thanks in advance!
Also, it seems there was a solution to kill processes in Windows 8 which is no longer supported in Windows 10 applications (Process.GetProcessByName .... or FindWindow)
Perhaps there is someway to kill a Windows 10 process by name?
You can't do that.
All the Metro-style applications work in the highly sandboxed environment and there is no way to directly start an external application.
Taken from this article
maybe the solution is creating a proxy.
How to Start a external Program from Metro App
This could help you, because you can kill the process indirectly.
I hope this helps.
I've found the following question asking whether it's possible to find out whether an app update is available:
Programmatically check Windows Store App update
(Not my primary question, but is there a better way?)
I know that it's possible to configure Windows 8.1 to auto-update apps, but this doesn't always happen as soon as I want.
So, now I know that an update is available, can I trigger the update from within the app?
If so, would this trigger have to take me through the Windows Store (which won't be possible in my scenario as I'm running in kiosk mode) or can it just start the auto-update?
Any thoughts/ideas on how I might be able to achieve this would be greatly appreciated.
Thanks
I've run into this problem as well.
What you can do is to check to see if there is an update available, then notify your users that they can either wait or update manually (through the Windows Store app, which you can open for them). You can also notify them of the importance level of the update (just UI fixes/additional features or is it a critical security patch?).
Lastly, you can also register the users for toast updates via an Azure Notification Hub, then send out a toast notification about it.
If it's truly critical, you can also include code in your app to do something like lock down unless it's fully updated or something similar.
In my experience, as of right now, these are our only options. Maybe one day they'll allow us to force an update via a Background Worker or something while the app isn't running. As of right now, that's not an option though.
How can I update my tiles in the background while my app is not running in the foreground? I tried looking into push notifications, but I don't think that'll get me anywhere.
Where to begin? I know how to create tiles already.
An app cannot update it's tile without running at least once. Because apps do not run immediately on installation, it isn't possible for a tile to be "live" until it is launched. After app installation, the user needs to launch the app for it to set up and begin receiving updates in any form (whether they are push notifications, periodic updates, scheduled notifications, or local notifications raised with or without a background task). The default tile will be shown from the point the user installs the app until the time the app sets up tile updates.
MSDN has a good article on choosing the right notification delivery mechanism, which also links to related code samples:
http://msdn.microsoft.com/en-us/library/windows/apps/hh779721.aspx
As far as I know, you have to use a background task. If the user hasn't run the app once, you can't show any interactive tile data.
You have to use a TileNotification from the Windows.UI.Notifications namespace. The documentation for the namespace is here.
There's also an example Stocks app that uses notifications here (search for 'Tiles and notifications')
Further, there's an 'App tiles and badges' sample that shows both text and image updates to a live tile.
Adding Live tiles to the desktop using c# code:
List<Uri> StoryUrls = new List<Uri>();
StoryUrls .Add(new Uri("tiles.xml"));
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdateBatch(StoryUrls, PeriodicUpdateRecurrence.HalfHour);
The xml should be in the following format:
tiles.xml should follow microsoft format show in step 5 Here
Hope this helps