Disable Application from sleeping in Windows 8 Metro - c#

I am working on an app which displays videos and am running into an issue where the machine goes to sleep after hitting the sleep time limit while a video is playing. Is there a way to disable this behavior in a Windows 8 Metro application?

You should use the DisplayRequest class, specifically DisplayRequest.RequestActive for this purpose. You must also remember to call DisplayRequest.RequestRelease once you are done to allow the display to sleep, for example, if you are not actively playing the movie, or in a menu screen, etc.

Related

Xamarin iOS - SignalR stops receiving messages in background mode

Currently i am developing an app which needs to be capable of receiving and interacting based on realtime event notifications from all platforms. We are using SignalR to achieve so. I am using Xamarin.Forms as this is a shared project.
Right now everything is working fine especially android is perfect. No matter application is in background or foreground its receiving messages from SignalR and playing sound and vibrates as expected. In iOS 10.3 simulator also its working as expected. Untill yesterday when i realized in real device when application goes in background mode it pauses everything and when its back in foreground it resumes as its supposed to be doing and as if the notification was sent just now. So i did some research and thought i would perform a long running task (in my case a forever loop with a 10seconds interval) in the background thread and in that way i was able to receive signalr messages (which i can see on the debugger) and vibration was playing while being in background. But after a certain time i am guessing within 10 mins iOS is clearing up its memory and when i open the app it seems reloaded because it shows the login screen instead of where i left the app.
Now question is:
1. How can i keep receiving SignalR events while being in background?
2. How can i stop iOS to reload my app due to being in background for a long time?
3. The app has to be Appstore publishable as in appstore must not reject it due to some dodgy works being done in the background like playing silent audio forever or using VoIP for background since this is not a VoIP app.
4. Also soon i am gonna be implementing location update in background mode so is this gonna keep the whole app alive in background? And behave like i am expecting?
As i am currently travelling i can not provide any code snippet but any questions please feel free to ask.
Thanks for your help and reading this boring article.
Just in case if someone is facing similar issue.
Apple doesnt allow to execute your app unless it falls in certain category Look at table 3-1. Fortunately, I had a valid reason to use continuous location update in foreground and background therefore as soon as I implemented location update event all my problems were solved immediately.
How to implement location update? Location DependencyService example for Xamarin.Forms
Hope that will help.

Windows 10 uwp sticky background service?

I'm trying to convert an Android app to Windows 10 UWP. On android its easy: when boot completed, app service is started. It connects to controller over internet, fetches system state and all data (temp sensors, pumps, valves, etc) and keeps everything in memory. Foreground app can get data as soon as service gets them and display values, charts realtime. After closing foreground app, service keeps working, I still have all system state and I can play alarm sound if needed.
Is it possible to do [almost] same functionality on Windows 10 uwp?
I cannot find a way to start service with windows. Service started with foreground app is stopped when foreground app is closed. SocketBackgroundTask keeps connection perfect, but system state is lost with service.
Should I save system state to file and analyze all data after each renew? Data flow varies from once in 10 minutes to ~10 per second.
Or should I forget Windows 10 as limited platform?
I am designing a similar piece of sensor control software, and I have found UWP/Win10 to be limiting. We ultimately resorted to using Assigned Access to keep the app permanently in the foreground.
Assigned Access
Assigned access assigns an app to an account. So when Mr. Bob logs in, the app starts full-screen, and it cannot be closed, and if it crashes, it is restarted.
Note that the only way to access other parts of the system is to hit ALT-CTRL-DEL and log in as a different user. That might be bad for some, but if you have critical process monitoring going on, then it's probably a good thing that the user can't mess about with the system or quit the app.
It's also quite simple to implement, you only need to add a declaration to the app manifest, and you need Win10 Pro or Higher.
Windows IoT
You could also look at Windows 10 IoT, when you deploy an app to it, it does pretty much the same thing. However the range of hardware is quite limited, and many of them aren't fully functional yet - RPi suffers from SDcards being inherently unreliable, and lack of graphics acceleration. Dragonboard lacks driver support for resolutions other than 720p, etc. https://developer.qualcomm.com/forum/qdn-forums/hardware/iot-development-platform/29652
Extended Execution
In addition we have experimented with using extended execution, which lets the app run in minimised state, potentially indefinitely. I have mixed feelings about it. Although the app will keep running most of the time, but if the OS is struggling for resources, the app will get suspended and won't be restarted until the user switches back to it.

Minimize Windows 8 Store App while tracking location with GPS

I'm working on a metro app and am having trouble finding how not to show the application.
We recently deployed tablets to our field reps, and need to add gps tracking. GPS is much easier to deal with in the metro libs (it's like 4 lines of code vs. unmanaged) so we're hoping to be able to push a metro app instead of spending time coding a winforms/wpf desktop app (the tablets are full version windows, so it's an option if we can't hide a metro app. I feel like it should be possible though as the start screen tiles update automatically without opening the main program).
In WPF, it's fairly simple to make a window invisible. I'm creating the metro app in wpf, but it uses different libs than desktop and I may just not know how to do it.
In desktop programs, it's fairly simple. You do something along the lines of:
<Page
x:Class = xxxxxxxx
..
Visibility="Hidden">
Unfortunately, with metro, the only options I have are collapsed and visible. Collapsed doesn't seem to have any effect, unless it's just because it's not deployed and visual studio shows it anyway...
So basically I'm trying to figure out if there's a way to start the program minimized or hidden so that it doesn't interrupt the field reps every time it takes their location.
If you really want to make a metro app and want it to run "minimised" you will need to look at background task. To start the background task the user would still need to start the app at least once, futhermore background task have limitation how how often and how long they can run. Also there is a lot of constraint on deploying a windows store app if you cannot publish it in the store.
If your goal is to just have access to GPS through C# apis, the GPS is actually one of the winRT api you can use from the desktop, you can find a tutorial on how to access winRT api from the desktop here
Here is the complete list of winRT api accessible from the desktop (You can find Geoposition class among them).
Have you looked into creating a background task that transmits GPS? The background task can run without the app running.
I am not entirely certain you can voluntarily minimize a Windows Store App on a user's behalf. I see nothing in IntelliSense about it, nor have I found anything online or see any app do it.
However, be aware that deploying the app without using the Windows Store -- sideloading -- requires Windows 8 Enterprise edition computers joined to the domain OR Windows 8 Pro with a sideloading key ($30 per key, purchased in packs of at least 100.) Perhaps a WPF app with unmanaged code is worth the money and effort.

How to navigate to Windows Phone 8 start screen using C#

I have built a very basic sound board app by following video tutorial series on channel 9 [http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners]. Each page in the app displays a list of sound tiles, which on tap plays associated sound. I have extended the app to allow user to tile the individual sound to phone's start screen. Everything works fine upto this point.
Now whenever user taps the sound from start screen, I want app tile to just play the sound, however its navigating into the application at the moment. I have raised similar question on channel 9 and the video series author suggested me that its possible by calling NavigationService.GoBack method on OnNavigatedTo event. I tried that, however I am getting exception with message 'Cannot go back when CanGoBack is false'. Here is the channel 9 thread - http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-23-Testing-and-Submitting-to-the-Store
Appreciate if someone helps me to resolve the issue.
Entire source code of my app is available on GitHub at https://github.com/PrasadHonrao/WindowsPhone8/tree/master/SoundJabber
Thanks.
To programmatically exit an application, you can call:
Application.Current.Terminate();
Unfortunately, it will work only on Windows Phone 8, this method isn't available on Windows Phone 7.
You can't use navigationService.GoBack when you don't have navigation history.
When you are in your main page and you want to exit your application you can use NavigationService.RemoveBackEntry() for remove navigation history.
If you want play sound for a specifique user.Create Model ou uri sound as parameter.
For information:
when you use Application.Current.Terminate();.You don't pass in your app.cs.
the simplest you can do is Application.Current.Terminate();

Windows Phone turn flash on in background

I am working on a tools app and I need a way to turn on the camera flash when I click a tile, then keep it on in the background and turn it off once I click the tile again.
I don't need any help with the tile yet all I want to know is what I can do to turn on the flash and then keep it on. All the examples I have seen thus far simply pretend to be a camera and then turn the flash on.
Do you know of anything?
PS. I am planning on making this for WP 7 and 8 but if you know of a way that will on work on WP 8 that will also help me a lot.
The simple answer is no.
While the app is running, you can control the camera and turn on the flash. But as soon as you exit the app (Back button) or the app is suspended (due to a phone call or by pressing the Start button), the use of the camera is suspended.
Windows Phone does have Background Agents but these are very limited and do not allow access to the camera API at all (and many other APIs).

Categories

Resources