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.
Related
I'm new and currently working on a Xamarin.IOS app based on a Xamarin.Android app. I noticed that the Android native app does background tasks using a class called Service from Android.App and classes from Android.Support.V7.App and Android.Content. I'm just wondering if there's any similar solution for Xamarin.IOS, or do I have to do it completely from scratch?
From document Backgrounding in Xamarin.iOS,we know that:
In iOS, backgrounding is recognized as an application state, and apps
are moved in and out of the background state depending on the behavior
of the app and the user. iOS also offers several options for wiring an
app to run in the background, including asking the OS for time to
complete an important task, operating as a type of known
background-necessary application, and refreshing an application's
content at designated intervals.
IOS regulates background processing very tightly, and offers three approaches to implement it:
Register a Background Task
If an application needs to complete an important task, it can ask iOS not to interrupt the task when the application moves into the background. For example, an application might need to finish logging in a user, or finish downloading a large file.
Register as a Background-Necessary Application - An app can register as a specific type of application that has known, specific
backgrounding requirements, such as Audio , VoIP , External Accessory
, Newsstand , and Location . These applications are allowed
continuous background processing privileges as long as they are
performing tasks that are within the parameters of the registered
application type.
Enable Background Updates - Applications can trigger background updates with Region Monitoring or by listening for Significant
Location Changes . As of iOS 7, applications can also register to
update content in the background using Background Fetch or Remote
Notifications .
For more details, you can check:https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/introduction-to-backgrounding-in-ios.
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!
Is there a way for my application to auto-start after some time instead of a notification? Or am I constrained to just notifications?
The difference between Android and Windows Phone (you mentioned Android in your comment) is that Android allows you to do pretty much everything while Windows Phone is a very restricted system. So, unfortunately, the answer is no. (There are ways to launch your app from other places than the app's tile, though. See the end of the answer)
Why am I saying unfortunately? Of course, Windows Phone is a nice and seek operating system that runs wonderful even on low-spec devices like the Lumia 520. But that doesn't mean developers shouldn't get the freedom to interact with the Operating System and do innovative tasks.
But there are reasons Microsoft chose not to allow Autostart (or at least, restrict the area an app can access, not the autostart in particular):
it may irritate customers. Even if you show a message box, many customers just dismiss it without reading it and they wouldn't understand why an app would appear without their interaction
each feature would make the operating system slower and bigger. I don't want to say that an autostart makes the phone unusable, but here's a question: Do you need to run a registry cleaner on you PC from time to time? Yes, you do need to do so You even need to reinstall a PC form time to time. You don't need to do that on a Windows Phone. It just works and will always work (OK, that's maybe a bit too optimistic, but you get it...)
I also don't think an autostart is particularly useful on a mobile. Because each app runs full screen, the system would boot up to your app instead of to the start screen. I don't think the user will always want your app (most of the time, he'll want to look at his start screen or launch another app), so it would just be annoying. On a PC, you can use the auto start for small programs that should run in the background (for example, I've got a progamm that provides Git with my SSH keys that automatically starts up each time).
But as I mentioned above, there are other ways to launch your app. Using url schemes can be surprisingly powerful as you can put a button on a web page that will directly launch your app. Other apps will also be able to launch your app. But as it is not directly what you wanted to know, I won't explain it in detail and instead provide you wiht a gread link to msdn: Auto-launching apps using file and URI associations for Windows Phone 8
For such features you should look into: Windows Embedded 8.1 Handheld instead of the consumer version Windows Phone 8.1.
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.)
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.