Search code examples
androidgoogle-fit

how to turn On/off Activity Recognition in google Api Client Programmatically


I am working on a health app using google fit In which i have a setting option to turn On/Off Activity detection . I researched a lot but didn't get any solution for it . Can anyone tell me how to achieve this funtionality?


Solution

  • To stop activity recognition you have to do this :

    ActivityRecognition.ActivityRecognitionApi.removeActivityUpdates(
                    mGoogleApiClient,
                    getActivityDetectionPendingIntent()
            ).setResultCallback(this);
    

    Here is the documentation if you wanna have a look