A library to detect falls, frequent falls and shakes in Android devices, store data in local database and display notifications. Also a public API to get all the events from the database, you can get filter list of events as well.
Fallen also detects frequent falls, meaning any fall that happens again within 5 seconds of the earlier fall. You can also change its values.
I will support more event gestures in future.
A sample android app that shows how to use "fallen library" to detect falls and shakes and also frequent falls on an Android device. Display a list with all the events.
The following diagram shows the structure of this project with 3 layers:
- View
- ViewModel
- Model
- UI calls method from ViewModel.
- ViewModel initiates the sensors using the fallen library.
- Fallen starts sensing data from the sensors and store events in the local database and displays notifications.
- Apps gets all the events from the fallen public API.
- Information flows back to the UI where we display the list of events.
- Start sensing all fall events.
- Store the duration of events in the local database.
- Return all the events using the exposed public API.
- Display a list of all events with a live paged list.
-
Register the fallen service in your application manifest
<service android:name="com.example.uzair.fallen.events_service.EventDetectionService" /> -
Give the access of the application reference to the fallen library in the Application class
class AppHandler : Application() { public lateinit var fallen: Fallen override fun onCreate() { super.onCreate() fallen = Fallen(this) } } -
Start fallen by
fallen = (application as AppHandler).fallen fallen.startFallen( detectFalls = true, detectShakes = true, detectFrequentFalls = true)
Finally when you are over, stop the service
fallen.stopFallen()
-
You can also give some extra features to fallen like below
fallen.setFallDetectionMessages(resources.getStringArray(R.array.fall_detected_messages))//String array of fall messages fallen.setFrequentFallDetectionMessages(resources.getStringArray(R.array.frequent_fall_messages))//String array of frequent fall messages fallen.setShakeDetectionMessages(resources.getStringArray(R.array.shake_messages))//String array of shake messages
All Done :)
I will be happy to add more updates frequently :)


