Reputation: 197
I am interested to know how WhatsApp runs in Android background system even after cleaning it from ram cleaner. I made an Android app in which I started service and broadcast receiver but when I cleaned it using ram cleaner, both got stopped. Even sometimes push notifications are also not received when app is not running in background. So, I just wanted to know that how WhatsApp manages all this. I am just giving an example as WhatsApp because I found its system amusing.
Upvotes: 3
Views: 1615
Reputation: 20211
If you return START_STICKY
from onStartCommand()
, the system will automatically restart the service once it determines that it is not resource strained. Which means it will probably restart immediately if you have killed it using an app killer.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
http://developer.android.com/reference/android/app/Service.html#START_STICKY
Upvotes: 3