WP8 timer app under lock screen - c#

I have app with dispatcher timer. User set some interval(for example 30 sec) and press button start. App Each 30 sec play sound. All work ok. But when User lock phone timer stopped and nothing played. Can I play sound each 30 sec when phone is locked?

It is possible to keep the app running under lock screen.
Using Idle Detection, you can keep the app on, although screen is locked. Actually, it is not running in background, but in the foreground. Just the screen is locked. So, be careful not to drain user's battery.
You have to set the PhoneApplicationService.ApplicationIdleDetectionMode property to Disabled, for example in InitializePhoneApplication() method in App.xaml.cs:
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
Note that there are special certification requirements for this type of apps. Refer to section 6.3 (Apps running under a locked screen) of the following page:
Additional requirements for specific app types for Windows Phone

yes.
sure..
You can use the Scheduled Task Agent in windows phone.
using the Scheduled Task Agent, when you app is not running or stopped (not in background).
you can fire your Events.
For that you have to add the scheduled task agent into your project.
And in the ScheduledAgent.cs file find the OnInvoke method and put your code here.
this method performs the task in Background. (Means the code is executed when your phone is locked).
for more Reference click here Implement background agents for Windows Phone
I hope you get the destination. Now, just put that code into your application and its working.

Related

Windows sleep even for UWP apps

In my app I have UP and DOWN channels which continuously listen for Audio stream.
I want to know that In windows is there any event which will tell me that machine is now going to sleep state (not sign-out because machine will go to sleep after sign-out based on the user settings) so that i can suspend the channels and once machine wake-up(Not sign-in because machine wake up before the sign-in even) then i can resume it again.
Something similar to Cortana
Thanks in advance.
There's no 'sleep' relevant APIs for you to detect if the windows will go to sleep in UWP.
If you check the Windows 10 universal Windows platform (UWP) app lifecycle, you will find that Suspending and Resuming are the right events to listen to.

How to run a long running task when my uwp application is suspended?

I have an UWP application, which executes some long running task for up to 1 or 2 hours. When I minimize my UWP application, the status of my application turns to Suspended and my long running task is suspended too. I wonder whether I could keep my long running task doing its job while my UWP app is suspended. I want this work for desktop, tablet and laptop.
Seeing from this post, using ExtendedExecutionSession can only run a task less than 10 minutes if no wall power for desktop; for tablet or laptop, it could run as long as screen is on, up to the battery.
I also looked into background task or background transfer - it seems background task not supporting work like mine; and background transfer only supports file transfer.
The only option I could see now is a win32 application, I could include it as part of my uwp application. And I could launch a process for the win32 application, pass info from uwp to this win32 by app service connection, then when my uwp application is suspended, my win32 application could go on working on the long running task. After my long running task is done, I can activate my uwp application to resume.
Is there any other option I could take a look here? Is there anything wrong to use the win32 process to run my long running task when my uwp is suspended? I have experimental code to package them in one appx, uwp can launch win32 process, and they can communicate to each other. Any input or concerns or suggestions are welcomed!
If you are writing your UWP app for personal use/sideloading, and NOT the app store.. this MSDN link answers your question.
From that link:
"If you are developing an app that is not intended to be submitted into the Microsoft Store, then you can use the ExtendedExecutionForegroundSession with the extendedExecutionUnconstrained restricted capability so that your app can continue to run while minimized, regardless of the energy state of the device.  "

UWP Background Task System Shutdown

I'm learning Win 10 UWP and my goal is to write an SQLite database entry every 15 minutes using a background task.
My question is, what happens to the background task when the user shuts down the system and restarts it later on?
As I can understand, the user has to start the application again manually to register the background task again. Or is the background task somehow registered somewhere and restarts when the system is back up again without having to manually restart the background task again?
Once you've registered your background task, it stays around even after the computer reboots. The user doesn't have to launch your application again.

How can I suspend my Windows 8 Pro app earlier than normal after being minimised?

I am building a Windows 8 Pro application and I would like the application to enter "Suspend" state immediately after losing focus (or being 'minimized')
This is for a kiosk application (won't actually be on the Store) where I want to relaunch/refocus the application when a user tries to hide it. So far, I can only 'refocus' it using a native C# app once the app has been killed (i.e. when the process does not exist in Process.GetProcessByName()). This is why I would like to kill the application-- the user should not be minimizing it so killing it is a cost the application can bear.
How can I get the application to terminate when it is minimized? I am wondering if it is possible to set the time-out period, or to intercept a general event in App.xaml.cs when the application itself has lost focus (then perhaps call App.Exit() terminate the process). I have tried the Application.Suspending event but takes too long to fire off. It takes about 10 seconds to fire off AFTER the application has been killed with ALT+F4.

How to set the expiration of a background task agent in windows phone 7 to never expire?

I am designing an application where the user selects the option to update his live tile and can forget about the app. Once he picks the option to update, I kick off a background task agent. But it looks like as per msdn, the background task agent will only run for upto two weeks.
How do I fire it again without having the user to come into the app?
It's not possible to run a Background Agent without rescheduling it every 14 days. Moreover, if the phone is in the battery-saving mode, it may not run the agent. So, you should find a better way to update the tile (Tile Push Notification).
Or, if you want to go with the Bckground Agent, the day before expiring, update the tile saying that the user should open the app to continue getting the tile updated. But, if he info is useful, the user will tap on the tile to get more info.
This has changed in Windows Phone 8. If the user has chosen your app for any of the lockscreen settings (Background, Content, or Status) the app will continue to run after the two weeks without the need for a launch by the user.
So if you have an application that the user decides to use as a part of their lock screen you are ok.
Otherwise I would go with setting a reminder the day you are going to expire. Each time the app is launched delete the reminder and make a new one two weeks out.
I also liked one of the comments above to change your tile status to "Launch me to get more updates".

Categories

Resources