This is a sample app which uses Android background service in the flutter where the app get the transition activity events from the API and submit it to the flutter view from the Android platform code
References -
Flutter platform channels - https://medium.com/flutter/flutter-platform-channels-ce7f540a104e
Android Background Service - https://developer.android.com/training/run-background-service/create-service
Android Activity Transition API - https://developer.android.com/guide/topics/location/transitions
Android Activity Transition API Codelabs - https://codelabs.developers.google.com/codelabs/activity-recognition-transition/index.html?index=..%2F..index#0
Source code - https://github.com/sriharsha1507/flutter_background_service_activity_transition