Simple Implementation of background code (bound services) For Flutter
  • Java 49.8%
  • Dart 31.5%
  • Swift 8.8%
  • Ruby 6.2%
  • Objective-C 3.7%
Find a file
Bernard Joseph Jean Bruno 913d3876cb
Update README.md
2019-06-20 02:05:12 +04:00
android Initial Commit 2019-06-20 01:59:44 +04:00
example Initial Commit 2019-06-20 01:59:44 +04:00
ios Initial Commit 2019-06-20 01:59:44 +04:00
lib Initial Commit 2019-06-20 01:59:44 +04:00
res/values Initial Commit 2019-06-20 01:59:44 +04:00
test Initial Commit 2019-06-20 01:59:44 +04:00
.gitignore Initial Commit 2019-06-20 01:59:44 +04:00
.metadata Initial Commit 2019-06-20 01:59:44 +04:00
bound_service.iml Initial Commit 2019-06-20 01:59:44 +04:00
CHANGELOG.md Initial Commit 2019-06-20 01:59:44 +04:00
LICENSE Initial Commit 2019-06-20 01:59:44 +04:00
pubspec.lock Initial Commit 2019-06-20 01:59:44 +04:00
pubspec.yaml Initial Commit 2019-06-20 01:59:44 +04:00
README.md Update README.md 2019-06-20 02:05:12 +04:00

bound_service

Bound Service In Flutter.

Getting Started

This is a simple implementation of a bound service in Flutter. This is based on Android documentation (Bound Services).

Bound Services let you run background code inside your flutter app, even the application is left or open as it uses binding and unbinding of a service.

The simplest way to explain it:

  1. You run flutter application with Flutter Platform Channel For Android
  2. This implementation let your code in Java run in background. Ex. Music, downloads, recording, background location.
  3. When the user leaves your application, the background code will remain opened until it is explicitly closed (by the application or OS).
  4. Since it's a bound service, the service should be bound to an application (obligatory).
  5. If the application is killed, the service is killed also by the system.

Files to check the codes:

  • bound_service.dart -- in charge of communicating with Java
  • main.dart -- Top level communication with Java
  • BoundServicePlugin.java -- It is the plugin where all your background code which runs
  • LocalService.java -- contains all your Local Services in form of public methods, of whatever tricks you would like !