Control application execution under any condition in WP8 - c#

I'm trying to build a basic tracking app for Windows Phone 8. However I can't figure out which model to use. The app shall log the location in a definable interval (e.g. 5 sec or even 2 hours).
If I develop the app as an foreground application the tracking will stop if the user opens another program, the screen locks (you can configure the app to continue running under the lock screen), or you reveice a phone call. Overall the risk of the app not being executed is to high.
There are also background tasks that are scheduled by the OS, and are only allowed to run a few seconds or minutes depending on the current state of the phone. Is there some workaround to schedule the background task execution as defined by the user? E.g. the Email client can be set to fetch emails every 15 minutes, therefore there must be some way.
The thrid option would be using the push notification service. This however seems stupid as some third party Microsoft server has to be involved and other limitations may apply. And more importantly, the app must run to receive the notification.
What is best practise on this? I don't care about battery drain as long as the app works as wanted. Similar solutions must exists for tiles that shall be updated more frequently (30 minutes or even more seems awfully long)? Am I missing something?
A basic app that can call it's own sleep would be great, but if it get's killed after a few seconds, that won't do it. Or does sleep time not count?

I'm afraid you can't do anything to make sure about your app execution.
Standard foreground application is always less important than things like incoming phone call, so you have to assume that it can be paused or stopped at any time. You also can't force user to use your app - that's why user is able to exit the app at any time.
Background execution on Windows Phone cannot be made permanent - that's how that OS is designed. And mail application is not a good example because it's a build in app. It was made as a part of that system, so it has another set of rules (if any).
I don't really see a way to do that using Push Notifications. But even if there is one, I'm sure it's not how that feature should be used.

Related

UWP: how to run a task without slowing down?

i'm developing an uwp app in c# capable to play midi files. I created a ThreadPoolTimer to scan a tick of 1 ms and other ThreadPool to run an async task that launch the midi messages of files relative to the time scanned by tick. It works correctly however when i do some other operation with laptop it throw a slow down behaviour. Mainly when i turn the gui in background. I changed the ThreadPool.RunAsync() with a Task.Run() and it works better but i'm trying to understand what is the best way to do a real time app with uwp because i need to implement new tasks. Additionally, i want to change base priority of my app programmatically because it works better with high priority but i don't want to change it manually everytime.
Ho can i do this tasks? i'm searching on internet but i not found any useful information about this in uwp.
Thank you
Edit: I want to use this app for play music so i need to develop it with high performance feature. For this cause i need to launch it directly with high priority level.
maybe can i develop some library

Is there a way to keep internet connections / sockets open after iOS forces app into sleep mode?

I'm developing a Xamarin app that uses location background modes to keep itself awake in the background, scan and report on iBeacons in its range over AMQP, and also make HTTPS requests to a log server.
This all works great, until a sustained period of time where the GPS location does not change and there are no changes to the radio frequency environment (i.e. no new iBeacons introduced, none taken away).
It appears that iOS puts the app into sleep mode (it's a slightly different sort of sleep mode to normal, as background modes are involved, so I don't see an OS callback for this). Moving the phone, or introducing new iBeacons wakes the phone up, but sometimes the app is no longer able to access the internet, using objects that were created before the app was sent to sleep. It appears as if the kernel is closing sockets.
Any ideas as to how I could diagnose this issue more effectively, or suggestions to how I can keep these sockets open, would be most appreciated.
Thank you for reading!

How to Grab Amtrak Scheduled/Estimated Data for a Given Train/Station?

Due to the nature of my commuter Amtrak train back home being late 10-20 minutes late the past few days, I want to develop a Windows 8 Metro/Desktop app that will notify someone given a train number and station what the status of the train is at a specified time so they know if they can clock in a few more minutes at work or not. Even though I've never done Windows 8 app dev (although I have done some dev in C#), toast notifications are well documented (http://code.msdn.microsoft.com/windowsapps/toast-notifications-sample-52eeba29). However, I can't find anything concerning Amtrak data.
I know there has to be some sort of general methodology to fetch the scheduled and estimated arrival/departure data as their Android app has this feature. How do I pull this data using C# so I can put it into the app's variables?

How location tracking is different than other background task?

In Windows Phone 8, it is suggested that, if I use LocationTracking as suggested in following code, my application will get location information continuously.
<BackgroundExecution>
<ExecutionType Name=”LocationTracking” />
</BackgroundExecution>
Now, Background Agent only executed after ~30 mins, and which is also with lots of limitations, like, it may run or may not run depending on OS.
How LocationTracking is different than Background Agent. Will it gives location every time location changes, or still it may invoke after 30 min.
Thanks.
As MSDN says:
On Windows Phone 8, a location-tracking app can continue to run in the background after the user navigates away, as long as the app continues to actively track location. This feature enables scenarios such as an app that provides turn-by-turn directions. For a walkthrough of creating a simple app that runs in the background, see How to run location-tracking apps in the background for Windows Phone 8.
There are also more differences and you must look out for API restrictions.
You can compare it with Background agent unsupported api.
And you should also be aware of some Additional requirements for specific app types.

BackGround Task not working in a window phone 8 beta app

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.)

Categories