How to create activity recognition android app in android studio

Опубликовано: 06 Май 2026
на канале: Coder Vlogs
1,463
9

Support me through paypal :

========= paypal.me/CoderVlog

My favorite Gadgets :

1. keyboard : https://amzn.to/3dh2AMS
2. Mic : https://amzn.to/2WACxKD
3. Laptop : https://amzn.to/2UeJMGF
4. DSLR : https://amzn.to/2UBmFVU
5. Mobile : https://amzn.to/3boSNTn
6. Mouse : https://amzn.to/2WBO4JK

blog link : https://codervlogs.com/activity-recog...

Official Website : https://www.codervlogs.com

official programming facebook page :   / saify333  

official personal facebook page :
  / saify3333  

follow me on Instagram :
  / saify9999  

Download Demo of this app from play store

https://play.google.com/store/apps/de...


In this article, I will teach you how to detect user activity through android app, you can detect these user activities like still, walking, running, cycling, tilting, driving etc. In this article, we will be using ActivityRecognitionClient API. This API is frequently used in fitness app for taking user information about number of steps taken and how much distance user travelled in km. So if you learn, this API it will be very useful for you in future.

Practical Implementation:

I am using background service for this app, which means i will fetch user activity in background and your app will fetching user activity when app is in background state. so you need to stop fetching user activity explicitly.

1. Add this permission in your manifest file.

uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"

2. Add this dependency in gradle file and sync your project.

implementation 'com.google.android.gms:play-services-location:17.0.0'

3. Create class for background services

4. Create class for constant

5. Create class for broadcasting user activity

6. Create main activity, this is main class. All control are given to this activity and from you can initialize background services and use user activity broadcasting.