I am wondering why ActivityRecognitionClient has no way to request updates with a standard java listener as a parameter?
Many good questions give rise to a certain opinion based on expert experience, but the answers to this question will, as a rule, be almost entirely based on opinions, and not on facts, links or specific experience.
Also, citing the documentation for requestActivityUpdates() :
A common use case is that the application wants to track actions in the background and take action when a specific action is detected. To do this, without requiring a service that is always in the background resource consumption, the detected actions are delivered with intent. An application defines a PendingIntent callback (usually an IntentService) that will be called when actions are detected.
It seems that IntentService is the only option for handling updates from ActivityRecognitionClient.
This is not true.
So far, does anyone know if it is possible to use BroadcastReceiver to handle updates from an ActivityRecognitionClient?
There are several types of PendingIntent created from various factory methods. The sample shows using getService() to create a PendingIntent that will call startService() . You can use any other PendingIntent , for example, one of getBroadcast() , which is called sendBroadcast() .
source share