PersistenceService¶
-
public class
PersistenceServiceextends Service¶ This service ensures that if the app is backgrounded, it will start back up again within 5 seconds, given that it’s not the system using one of its extreme measures, so that measurements are taken as long as possible. This means that if you install the app on your phone - it’s really hard to get rid of until you adb uninstall it.
Author: Alan Zhu
Methods¶
onBind¶
-
public IBinder
onBind(Intent intent)¶ Not useful.
Parameters: - intent – intent that started the service/binder (?)
Returns: null
onStart¶
-
public void
onStart(Intent intent, int startId)¶ This is the old onStart method that will be called on the pre-2.0 platform. On 2.0 or later we override onStartCommand() so this method will not be called. This came with the Android tutorial and I’m not quite sure why we still have it.
Parameters: - intent – intent that started the service
- startId – honestly I’m not sure, but it’s not important for us really
onStartCommand¶
-
public int
onStartCommand(Intent intent, int flags, int startId)¶ Starts a thread that checks if the app is in the foreground and puts it there if not.
Parameters: - intent – intent that started the service
- flags – any flags, although we really don’t use them
- startId – not sure, not important
Returns: START_STICKY, so that our service is kept (hopefully)