- Home /
How to regularly send messages(ping) to server when the program running in the Android background?
My ping message write in the update function, but it seems that the update function dosn`t run when the program running in the android background. So what can I do if I want do something in update function when the program running in the android background?
Please don't post the same question several times. I have rejected your other question.
I'm curious, why would you want to do this? Android programs do not run in the background, so people do not expect backgrounded apps to consume resources. And even if you could do it, it's hard to see what the point would be since your app won't be able to do anything with the information. So why can't you just ping when the app is unpaused?
Answer by Mefistofel · Nov 14, 2013 at 05:41 PM
There is no standard ways for that in unity. Unity for Android runs in Activity, when minimized, it loses control. Desired functionality have android Services, you can integrate them, making plugin, writing the desired functionality in it, registering a service in the android manifest, etc. To do this, you need Unity Pro and understand the base android architecture...
if i create new Thread in unity application, this thread is working in background?
Not reliably. An android process that has moved into the background can be killed at any time when the system needs the resources. That's why things like services exist. There is only one foreground app at a time.