cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
540 stars 647 forks source link

Isolate StateStreamSubscription / Listener [Flutter screen_state 1.0.1] #244

Open Bar2d2 opened 3 years ago

Bar2d2 commented 3 years ago

Description

I'm currently working on a project (for Android), in which I need to get noticed about screen state ON/OFF even if my Flutter App is closed and user click "Back" button that kills my main activity.

Is it possible somehow to isolate this stream screen state and config listener(?) that could work not only with app main activity?

Thank's for any help or advice how to achieve that.

thomasnilsson commented 3 years ago

I would look at using a foreground service, this is what we did in the Activity Recognition plugin.

Check out this package https://pub.dev/packages/foreground_service