I have a Windows 8.1 app where I need to play audio, also when the app is in background and under lockscreen.
In Package.appxmanifest, in the declarations section I add Background Task and set it to Audio. So far so good, the audio playback continues when U switch from the app to another app or to the desktop.
Now I need the playback to also continue under lockscreen, so I add the Badge Logo assets, and set Lock screen notifications: badge, so the app can work under lockscreen. But the project does not build:
App manifest defines lock screen notifications without specifying one of appropriate background task types: timer, control channel, push notification, or location.
But I do not need any of those functionalists. Adding one, like location, just so it builds and works seems really strange.
What is the correct setup to allow the app to play audio under lockscreen?
Related
I want to control the external running Windows Media Player application using C#. For example, I want to send the play or pause command to the process of the running exe-file "%ProgramFiles(x86)%\Windows Media Player\wmplayer.exe", which was started by the user and is playing a playlist. How can this be done instead of embedding a windows media player control?
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.
I have Win32 desktop bridge application that uses background task to receive push notifications from WNS. I use UWP background task APIs over C++-WinRT
I'd like to be able to receive push notifications even when OS is in sleep so that it wakes up and the app handles push notification. By default OS does not wake up. It did only after manually changing settings value in System->Battery->See which apps are affecting your battery life->Click my app ->Uncheck Let Windows decide option (by default it is always checked) and check Allow the app to run background taks. Now I'd like to do this is manual work on code for better user experience.
RequestAccessKindAsync API allows to let user to change above setting value by showing popup notification to the user and I could do it without any problem in UWP C# sample app. But same code does not show pop notification from my desktop bridge over C++-WinRT. It simply returns false value for below code
auto result = co_await BackgroundExecutionManager::RequestAccessKindAsync(BackgroundAccessRequestKind::AlwaysAllowed,
L"App needs to use background to catch push notifications while device is in sleep");
Can anyone confirm that RequestAccessKindAsync API works from desktop bridge? If not then how I can make sure OS and the app will always be able to wake up from sleep when it receives push notification?
UPD: Raised request to enable this API from desktop brige here
This is a missing feature. When we designed this API a couple of releases ago we didn't consider desktop bridge apps would be calling it - but clearly there is a use case for supporting this. I have notified the team about this gap, but I'd also encourage you to log a feature request here: https://wpdev.uservoice.com/
Two possible workarounds:
(1) you could add a dummy/empty UWP foreground app to your desktop bridge app. You can then launch this on startup and request the background access from there. This will be a bit ugly, but you could make it look like a splash screen :-)
(2) you can instruct the user to go into the Settings app to set your app to always allowed. You can help them do that with a deep link to the battery save settings, but they will still need to manually flip the switch.
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.
I am developing a Windows Phone 8 application, and I've implemented a background agent which does some work and also updates my application's Tile and shows a toast notification to the user.
It works, except when I am launching the application (more specifically when control is in the Application_Launching event) in which case the Toast notification is not shown, but the Tile still gets updated. Has anyone ran into this before?
A toast will not be displayed if the current foreground application is the caller of the Show method. Toast notification only display in the running background agent or some of the work are finish.