4

There are two option to play activities in Android:

1st: Detecting the activity in specific time intervals:

  public Task<Void> requestActivityUpdates (
           long detectionIntervalMillis, 
           PendingIntent callbackIntent
       );

2nd: Handling specific activity/activities by catching them in transition:

public Task<Void> requestActivityTransitionUpdates (
          ActivityTransitionRequest activityTransitionRequest, 
          PendingIntent pendingIntent
       );

Second choice has not a detection interval argument. So how many times does it check sensors in a minute is not clear.

I wonder that which one should be used when considering the battery impact?

efkan
  • 12,991
  • 6
  • 73
  • 106

1 Answers1

3

Answer is requestActivityUpdates. As it only makes use of low power sensors in order to keep the power usage to a minimum (Reference link). But these can't be compared anymore as requestActivityUpdates is deprecated and you can only use requestActivityTransitionUpdates (Reference link).

Prashant Abdare
  • 2,175
  • 14
  • 24
  • 1
    Thank you for making me aware of ActivityTransitionUpdates! I also wasn't aware that requestActivtyUpdates where becoming Deprecated! Thank you :) – Andrew Irwin Aug 02 '18 at 09:55
  • 3
    You can still use `ActivityRecognition.getClient(mContext).requestActivityUpdates` its not deprecated – edhair Oct 30 '18 at 11:56
  • @Prashant i would change the answer to clarify what @edhair pointed. `requestActivityUpdates()` is not deprecated. – NoamStolero Oct 09 '19 at 11:08