Background agent doesn't run when battery saver mode is on - windows-phone-8

I'm using a PeriodicTask that works flawlessly, but it doesn't run if the battery saver mode is on, even though I've allowed the app to run in the background in this state via the Battery Saver app.
Any ideas what may be causing it from not running? I should add that I'm generating a new front and back live tile image using Telerik's LiveTileHelper control inside the background agent, and that a http request is made too (the app is a weather app). This is for a Silverlight Windows Phone 8 app.
Apologies for being quite general with the problem, but am assuming the explanation doesn't require me to share code.
Any insight will be much appreciated.
Bardi

This is by design.
In battery saver mode the background agents do not run, including of course your background agent.
You can’t allow an app to run in the background in this state via the Battery Saver app.
Instead, you can forbid the app to run in the background even when the phone is in the normal state. But in the battery saver state no background agents are allowed regardless on the settings. The only thing that can be done with it — completely disable the battery saver state.

Related

Do tvOS transmissions stay active since there is no drain on battery?

Two part question:
First, does the Apple TV run app activities in the background while it is asleep? I would assume this would be the case since the Apple TV isn't relying on battery.
Second, if this is not the case, how would I override this keep an app running and writing to my database?
I am building an app that connects to Bluetooth LE, then writes to a database after connecting. I would like the Apple TV to be the "hub" for my device. So as long as the Apple TV can stay awake, unlike iOS, I should be fine. I could be looking at this the wrong way. Please feel free to correct me.
tvOS runs the same application state mechanism that iOS does. Meaning it has the same old:
not running > suspended > background > inactive > active
This also means that it will do basic background processing based on very specific background tasks you specify, just like iOS. Though, tvOS does not have a background data-refresh function, which I'd imagine you'd want to use for the scenario you described.
Check out this Apple doc for more modes. https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW22
To specifically, answer the question: There may be a way to do some background data work, but it would be very limited; And you can prevent sleep programmatically by doing:
[UIApplication sharedApplication].idleTimerDisabled = YES;
This apple doc will give you all you need to accomplish this.
https://developer.apple.com/documentation/uikit/uiapplication

Long-running task performed in foreground is suspended when app goes to background

When a user first opens my app, I need to download and install some content from a server before they can begin using the app. The problem is that this takes around 5 minutes on wifi, during which time the app goes into the background and the download is suspended.
Is there any way to either:
Prevent an windows app from entering the background while I perform my download
or continue peforming the task in the background (i.e. perform the task irrespective of whether the app is in the foreground or background)
Also, I don't want to use the BackgroundDownloadManager
Thanks
When the app is being suspended, all processes are stopped and and background task cancelled. Your last chance to do something is Suspending event - see more at MSDN.
In your case, when you need to download big file in the background - the mentioned BackgroundDownloader would be the best option - it's designed for such tasks. In other cases you will have to convince user to leave the app in the foreground (a message?), also take care about lockscreen (see DisplayRequest class).
I'm not also sure but maybe you will be able to use BackgroundTask (separate process), triggered with MaintanceTrigger - but then user will be able to download the file only in specific circumstances and probably not right away.

Run Windows Phone App in background without UI

I am developing a Windows phone 8 app that need to run only in background with UI. Is there any way I can run the app in the background, or without actually being open?
It depends upon what you want to do in the background. Generally speaking you can't implement something like a Windows service that will startup automatically when the phone is launched.
That said you can run your app in the background within given limitations. Check out MSDN for detailed information.
Why all these limitations you might ask yourself? It's to provide a good battery life to the user.
Edit:
For the periodic agent to start running the app must be started once. Further the agent must update a live tile (user must pin it to the start screen) or the app has to be once opened every 14 days.
Another option might be using push notifications to trigger an update..

Speech recognition api in a background agents on Windows Phone 8

My question -I want to use speech recognition API that work when application is in background. Is it possible.
While the speech APIs aren't in the list of Unsupported APIs for background agents for Windows Phone this does surprise me.
I suspect that you are actually trying to have an application which is always listening in the background but this is not what a background agent will do. At best it will only run periodically (approx. 25 seconds every 30 mins) and I assume that's not what you want.
There is no way to create an app that is always running in the background. Regardless of whether it is doing speech recognition.
I have never actually tried this, but I'd say I doubt that it is possible for the following reasons.
1) Background tasks run for a limited time period at a specific interval. The chances of the agent being active when you want it to be are very slight.
2) How would you notify your agent that you want to give it voice input if your UI is not running?

Windows Phone 8 - Keeping background location tracking active beyond four hours

I'm in the process of developing a WP8 app that makes use of the background location tracking abilities provided by the OS. The idea is to monitor the users position and to notify them when they are near certain types of places.
So far it all seems to work fine and when running the location tracking works as I would expect.
The problem is, it seems that the phone times out background apps after around four hours, stopping the location tracking.
I can understand why Microsoft did it, to preserve battery life etc. But there's not much point having a background location tracking app that has to be manually restarted every four hours! If a user chooses to run this app and is made aware of the potential battery hit, surely it should be able to run indefinitely - to a point of course, if the system runs out of resources or similar then that's fair enough.
Does anyone have any experience with this? There must be hundreds of others apps in the store that have run into this issue I would have thought? And presumably there must be some way of keeping the location tracking running?
I've tried periodically updating the live tile (using a DispatcherTimer) while the tracking is running but this doesn't seem to be enough to keep the app alive either :(
Anyone have any ideas?
Thanks.
There is no way to achieve your desired behavior. The app will be deactivated under anye of following conditions:
The app stops actively tracking location. An app stops tracking location by removing event handlers for the PositionChanged and StatusChanged events of the Geolocator class or by calling the Stop() method of the GeoCoordinateWatcher class.
The app has run in the background for 4 hours without user interaction.
Battery Saver is active.
Device memory is low.
The user disables Location Services on the phone.
Another app begins running in the background.
Source: Running location-tracking apps in the background for Windows Phone 8
What you could do is to show a toast notification before app is deactivated advising the user, and make him navigate back to the app, extending the period for other 4 hours that way.
There is no way to keep it running without any user interaction.