I'm facing a problem with background tasks in Windows Phone 8.1.
I tried to create a new background task with Device User Trigger and Audio, but I got the error saying:
Package could not be registered.
I saw this:
Windows phone 8.1 deployment error when trying to use background task with audio and device use trigger in SO
Windows phone 8.1 deployment error when trying to use background task with audio and device use trigger in the MSFT Forum.
I tried the solution they pointed but without success.
Anyone knows how I can make 2 background tasks communicate?
What worked for me was this:
in one of the Background Task (the audio one) I created a Timer and checked if a LocalSettings value was or not true.
The other Background task was the one responsible to set it to true, so that what I want to do in the audio will happen as soon as I set the value to true.
I know that this is a "strange" way to do it, but it works ;)
Related
I'm trying to bring over my C# WP 8.1 Background Audio Task to UWP and everything works, except trying to get the UVC using Windows.Media.Playback.SystemMediaTransportControls.GetForCurrentView() throws the current exception on Desktop devices: "Could Not Find an appropriate view to be associated with this instance of the MediaPlaybackControl. Please make sure that a view has been initialized".
Is it simply a behavior that has yet to be converged, or do I need to control and update the UVC via my app on Desktop class device?
There is an API change in Windows 10. It seems that you should use BackgroundMediaPlayer.Current.SystemMediaTransportControls. This is not in the documentation yet. You can find it in the Windows 10 sample repository: https://github.com/Microsoft/Windows-universal-samples/tree/master/backgroundaudio
I use background task with time trigger of windows phone 8.1 for update information and save it to offline, create a tile for notification for use.
I use Debug mode for testing on Emulator then every thing is ok, but every thing begin when I use Release mode for build in lumia 820 for testing.
Task is registered ok. But when BackGround task run, it close after some minutes.
I know there are some constraint about CPU and Memory for background task, but it is very hard for debug. Do you know any way for testing CPU and memory constraints? What is best practice for windows phone 8.1 backgrounds task?
I feel so tired with Background task of windows phone 8.1. Sometime it is ok, some time is none...
I recommend your assistance.
I am using Silverlight 8.1 to program an GPS based alarm app (Because the Microsoft.Phone.Scheduler.Alarm api is blocked in WP 8.1).
Now I am trying to create a BackgroundTask triggered by the GeofenceMonitor.
My problem is that a BackgroundTask must be located in a "Windows Runtime Component" project and you can't set the compilation target to Silverlight 8.1, so I cannot create an Alarm in there.
Is there a workaround or is it just impossible to launch an Alarm from a BackgroundTask?
I would appreciate every solution.
Unfortunately you cannot mix WinRT and WP8.1 Silverlight.
As you mentioned the Alarm API doesn't work with WP (so much for "universal") and the Silverlight Runtime doesn't have the GeofenceMonitor. You can have a Silverlight Project with a WinRT background task, but that won't get you anywhere.
I don't know if you want these alarms permanently associated with a location or rather short-lived, but maybe this would be a solution:
Configure your app to keep running in the background. There is a dedicated "LocationTracking" Execution Type that you can use for any app that tracks the GPS Position in the background (see this site for details).
You can then use the PositionChanged event of your Geolocator to check if you are within your fence and add an (almost) instant alarm.
const string id = "whateverYourIdIs";
var existing = ScheduledActionService.Find(id);
if(existing != null)
ScheduledActionService.Remove(id);
Alarm alarm = new Alarm(id)
{
BeginTime = DateTime.Now.AddSeconds(1),
Content = "You have reached your location!",
};
ScheduledActionService.Add(alarm);
If you don't want to keep your app running, you could (propably) launch another background task (SL) from within the geo-fencing background task (WinRT).
I'm developing a Windows Phone 8.1 app (non-silverlight).
What I'm able to do at the moment:
1-I'm able to activate a background task from the UI that reads the accelerometer readings even when the screen is locked or the app is closed using
DeviceUseTrigger
and
BackgroundTaskBuilder
2-I'm able to activate a background task from the UI that plays an audio file even when the screen is locked or the app is closed using the
BackgroundMediaPlayer.Current
Now what I need to do is to play an alarm from the first task even when there is no UI. In other words the first task should be able to Run the second one. Using the BackgroundMediaPlayer does not work anywhere beside the UI thread...
Any help or idea would be appreciated!!
Have you tried using the Windows.Media.Playback.MediaPlayer (MSDN Link) class by any chance? I'm not sure if that works in a background task but it might be worth a try.
I have created a Window phone 8 app. Which changes the lockscreen image and notification in around 30 sec randomly.
My code works well in the emulator and device. When I install it through the code. My problem is that when I have submitted the app to the store as a beta app. And now I install the app from the store the app don't work as it was working. The lockscreen content don't change it remains static. I have checked the settings background agents that app is running in the background tasks but not showing the result.
What could be the cause that app is running well from the code but not from the xap uploaded to the store.
Link of app is http://www.windowsphone.com/s?appid=00d47e34-a551-4c98-b2a6-32e10babdc2f
am I missing any capability that need to fixed.
Your suggestions are welcome.
Because your title says you are using a background task and you are trying to do something every 30 secs, I assume that you're using ScheduledActionService.LaunchForTest to trigger your background task and which then performs the updating.
ScheduledActionService.LaunchForTest is only supported in DEBUG builds as a way to aid testing. It is not possible to submit an app to the store that is built in DEBUG mode so this will not work.
It is not possible to create an app which will update so often in the background. To have such an app would, potentially, drain the battery really quickly and so provide a very poor experience to users.
The best you can do is to have the background agent run on a periodic schedule (approx. every 30 mins) or trigger the updates via push notifications. (But this wouldn't work for the lock screen image.)