Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Update documentation for connectivity #2328

Merged
merged 6 commits into from
Dec 5, 2019
Merged

Update documentation for connectivity #2328

merged 6 commits into from
Dec 5, 2019

Conversation

mehmetf
Copy link
Contributor

@mehmetf mehmetf commented Nov 28, 2019

We recently discovered that connectivity broadcasts no longer work in the background post Android O (API 26). In the long term Android wants to crack down on apps that awaken unnecessarily.

Apps should update their knowledge of connectivity when they are resumed if they are storing it. The plugin itself does not store current connectivity so the Dart API is not the appropriate place to do this.

@ened
Copy link
Contributor

ened commented Dec 3, 2019

@mehmetf is this also true for Flutter isolates running in foreground services? (I think the answer may be in my question already :)). If so, should we mention that as well?

@mehmetf
Copy link
Contributor Author

mehmetf commented Dec 3, 2019

@cyanglaz Please take a look at this PR.

@mehmetf
Copy link
Contributor Author

mehmetf commented Dec 3, 2019

@ened What do you mean by "this"? The connectivity plugin native code is not running in a foreground service.

To be clear, this issue does not arise because the isolate is killed. In this case, the isolate is alive and running, however the background service that delivers connectivity updates no longer does so post Android O.

@ened
Copy link
Contributor

ened commented Dec 3, 2019

Apologies for not being clear. I was wondering if an isolate+plugin owned by an Android foreground service would still be able to receive connectivity updates, essentially whether the BroadcastReceiver in the plugin fires.
And I think your current description "when your application is in the foreground" is good, then.

@mehmetf
Copy link
Contributor Author

mehmetf commented Dec 3, 2019

@ened Thanks for clarifying.

At its current state,

  • The plugin has no clue where your isolate is being run (activity? service? foreground service?).
  • Apps cannot change where the plugin is being inited. This plugin, for instance, uses registrar.context() to register the broadcast receiver. That's the application context.

Perhaps you are proposing to change the way the plugin is written to register itself in a foreground service? and wondering whether any plugin using a broadcast receiver can work around this by registering itself in a foreground service?

I would advise against that because every foreground service needs to have a sticky notification as long as it is running. Foreground services are reserved for actual critical work such as playing music. It is actually pretty rare that your app would need a foreground service. Android strongly encourages you to use background services or work manager jobs to do work. You should not be registering a foreground service just to listen to network changes.

@mehmetf mehmetf requested a review from collinjackson December 4, 2019 01:22
@collinjackson
Copy link
Contributor

Note that (per @amirh) we prefer to do CHANGELOG entries and pubspec.yaml updates even for purely documentation-specific updates.

@mehmetf mehmetf merged commit 3d45c01 into flutter:master Dec 5, 2019
@mehmetf mehmetf deleted the b02 branch December 5, 2019 01:23
daohoangson added a commit to daohoangson/plugins that referenced this pull request Dec 7, 2019
…flutter/has_gesture

* commit 'be71485431cd5ebaeb7cad4c57ddeb0be910d8b6': (74 commits)
  [webview_flutter] Add support for onPageStarted event (flutter#2295)
  adds missing [[ to elif statement in scripts/incremental_build.sh (flutter#2358)
  [none] Pass --custom-analysis flag through CI (flutter#2356)
  [video_player] Document public API of video_player_platform_interface. (flutter#2355)
  [none] Lock pedantic version (flutter#2354)
  [video_player_platform_interface] Fix some pedantic lints (flutter#2349)
  Export SignInOption from interface since it is used in the frontend (flutter#2350)
  Update documentation for connectivity (flutter#2328)
  [ android_alarm_manager ] Loosen Flutter SDK lower bound, update README (flutter#2338)
  [e2e_macos] Remove redundant analysis_options.yaml (flutter#2347)
  Revert "[android_alarm_manager] Update minimum Flutter version to 1.12.0 (flutter#2327)" (flutter#2345)
  [video_player] Add web implementation using platform interface (flutter#2279)
  [webview_flutter] Fix pedantic lint errors (flutter#2322)
  [google_maps_flutter] Add documentation (flutter#2303)
  [e2e] Fix pedantic lints (flutter#2315)
  [video_player] Fix pedantic lints (flutter#2321)
  [share] Fix pedantic lints (flutter#2320)
  [battery] Fix pedantic linter errors (flutter#2311)
  [device_info] Fix pedantic errors (flutter#2314)
  [in_app_purchase] Fix most failing pedantic lints (flutter#2317)
  ...

# Conflicts:
#	packages/webview_flutter/CHANGELOG.md
#	packages/webview_flutter/lib/platform_interface.dart
#	packages/webview_flutter/lib/webview_flutter.dart
#	packages/webview_flutter/pubspec.yaml
sungmin-park pushed a commit to sungmin-park/flutter-plugins that referenced this pull request Dec 17, 2019
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants