Looking into developing an app for WP7 that requires continous monitoring GPS position. From what I can read from some searching there are certain limits to WP7 background tasks. Only scheduled for execution every 30 minutes, run for no more than 25 seconds, etc.
I would like to know how to bypass these limitations to permanently run a background task capable of monitoring GPS in real-time. (Think of Google Latitude for instance.)
You can't do that unless your app is actually running on the phone.
No background task can be permanent on WP7.
Related
I am Working on Background task in Windows phone application but it is not calling .When do launch for test it is working but in real scenario app is not calling background services.
Do you use ScheduledActionService.LaunchForTest? This function is not supposed to work on a real phone. You have to deal with the fact that instead of running every 1-2 minutes your background task will be launched once every 30 minutes or so as stated in Constraints For Periodic Agents section.
If everything is fine in your simulator, you have to cross your fingers and keep waiting for a half of hour or so just to test that you are actually launched. Yes, it's a pain to debug, but we have no other official way.
You may also try adjusting local time on device. Sometimes going half an hour into the future helps trigger background agent immediately.
I have made an app with live tile for windows phone 8. The tile is programmed to refresh every 30 seconds. When the run the app in the emulator or when I deploy the app in my cell (Lumia 920) the tile works fine. But surprisingly when I downloaded the same app from the market and run it on the same device the tile doesn't update.
I did quite a bit of research on this problem and found that a similar problem is observed by many other people which can be found here.
Kindly tell me what is going wrong.
Extra Info : I have tried resizing the tile, pin and unpin the tile and hard reset. I have also tried changing the refresh period (initially the refresh period was 5 seconds). I have also checked that the background task is allowed for the app.
Thanks,
Apurva Pathak
Background agents have certain limitations, as listed below.
Background tasks can minimally be run every 30 minutes. There is a debug-only API to run them more regularly, but this is not available for released apps.
Some low power devices do not support background agents
Background tasks are limited by number on each device and can be enabled or disabled from application settings.
They do not work when power saver mode is activated.
As Mahantesh correctly pointed out your tiles work when you deploy the application because the ScheduledActionService.LaunchForTest() is allowed to run for a 60 seconds period for debugging and testing purposes ONLY.
Therefore this method cannot be called and it wont work with a time limit less than 30 minutes if the application is published to the market and users download it from there.
With the new WP 7.1 they added Background Agent to play sound files from within your application, and TaskScheduler Agent to run tasks periodically.
However:
I want to play sounds periodically even if my application is closed.
TaskScheduler does not allow to play audio via XNA sound effects, BackgroundAudioPlayer or MediaElement (http://msdn.microsoft.com/en-us/library/hh202962%28v=vs.92%29.aspx)
TaskScheduler runs for a specific time with a FIXED interval of 30 seconds. I need to play a sound every hour on the hour.
Alarms can have a sound set to them, but there is no way to customize that dialog to not show and not need snooze or dismiss functionality.
There's no way to play sounds from a Background/Live Agent as there is no way to implement the required UI prompts that would be needed to satisfy the marketplace certification requirements around other music which may be playing on the device at the time.
In theory you could create the functionality you are after with an hour long track that is mostly silent which you play via a background audio player. In reality though this would likely be a big drain on the battery and would prevent the user playing other music.
If you can explain why you want to do this we may be able to make alternative suggestions.
Also note that the length of time a scheduled agent can run for is a MAXIMUM of 15 seconds every 30 minutes (plus or minus 10 minutes).
Is there now a possibility to play the sound on the setting timer even if we close the application ?
Is it possible to create an app the runs in the background? If so is there any samples out there for this?
In Windows Phone OS 7.1 you can actually use Background Agents now to perform tasks in the background.
from MSDN:
Scheduled Tasks and background agents allow an application to execute
code in the background, even when the application is not running in
the foreground. The different types of Scheduled Tasks are designed
for different types of background processing scenarios and therefore
have different behaviors and constraints.
You can use a PeriodicTask or ResourceIntensiveTasks. Read more about it in the MSDN article above.
And here's some sample code for you to integrate background agents into your existing app.
Sample Code: Background Agents in Mango
An application in the foreground can continue to run when the phone screen is locked(not background but...) by setting the PhoneApplicationService.ApplicationIdleDetectionMode property. By setting up your application to run when the phone screen is locked, a user is able to access the application quickly upon unlock. However, when your application runs under a locked screen, it could consume power outside of the user's control. For this reason, your application must minimize power usage when running under a locked screen
At the moment there is no way to create application that runs in background.
True multitasking for 3rd party Windows Phone 7 apps will come as an OS upgrade later this year. However, unless the app has to absolutely run in the background (like Pandora etc.), we as developers share some responsibility in making our apps feel at home with the rest of the OS.
Windows Phone OS offers app developers chances to save state of their applications to give the end users the feeling that it never stopped running; this is essentially the same as in other mobile platforms. As your app is being deactivated/closed, you have the option to "Tombstone" your state so that your users can come back to just where they left with BackStack navigation or future launches. Channel 9 had a nice set of demos & labs around tombstoning, found here.
Hope this helps!
I'm a complete noob when it comes to WP7. From what I know of it, in WP7 you wouldn't be able to make an alarm clock app. As in, start app, set alarm for an hour from now, close app, app launches and rings alarm after an hour is up.
Is this not possible in WP7? Or is there some way of doing it that I'm not aware of? I have seen a workaround for a stopwatch using tombstoning, but that doesn't seem like it would work here.
With Windows Phone 7 [for 3rd party developers] it's not possible to write an application that runs in the background on the phone. (This was a deliberate decision with regards to maintaining performance and battery life - not a limitation of the OS which is fully multi-tasking.)
If you really want the user to be notified of something at a specific time, regardless of whether your application is running you'll need to have this monitored from a process on an external server and then send a [toast] notification to the user at the appropriate time.
Learn more about push notifications at http://msdn.microsoft.com/en-us/library/ff402537(VS.92).aspx