Can i run any code from WP8.1 universal app in background when device connect to internet? For example user work with app, but have no internet connection. App save data into local storage, user close app, then user come home and phone automatically connect to WiFi, can I run my code in bacground in this moment and for example upload data to ftp server
Asked
Active
Viewed 227 times
0
-
if it runs as a background process yes, but that would also eat up device battery while it runs in the background, so you need to optimize for that – Shashank Shekhar Feb 24 '15 at 15:42
-
But how can I know that Internet connection turn on? – Std_Net Feb 24 '15 at 15:45
2 Answers
1
You should be able to do this with SystemTrigger.NetworkStateChanged. Though, you must remember that there are some limits for using network in BackgroundTask - more about constraints you will find at MSDN.
For some help you may also take a look at this answer, you will also find a sample code there.
As for adding a BackgroundTask, take a look at MSDN, this blog post or this SO answer.