パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.1+1

foreground_service

Androidのフォアグラウンドサービスを介してDartコードを実行するためのFlutterプラグイン。Android Oではわずかにテスト済みであり、Mではほんの少しテスト済みです。iOSサポートは計画されていません。

30日間ダウンロード
25
いいね数
52
Pub ポイント
30

パッケージをインストール

flutter pub add foreground_service

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

DartコードをAndroidのフォアグラウンドサービスで実行できるようにするFlutterプラグインであり、アプリがバックグラウンドにある場合でも長時間実行されるタスクが継続することを保証します。主にAndroid O以降のバージョン向けに設計されており、古いバージョンでは最小限のテストしか行われていません。iOSサポートは計画されていません。このプラグインはAndroidのフォアグラウンドサービスのライフサイクルと統合されており、位置情報の追跡やオーディオ再生などの重要な操作をシステムによって終了されずに維持できます。Androidマニフェストでの適切な設定と権限が必要です。

用途

  • バックグラウンド位置トラッキング
  • 長期間にわたるデータ処理
  • バックグラウンドでのオーディオ再生
  • 恒久的なネットワーク接続
  • リアルタイムモニタリングサービス

主な機能

  • Androidフォアグラウンドサービスの統合
  • フォアグラウンドコンテキストでのDartコード実行
  • システムレベルの永続性
  • 最小限の iOS サポート
  • マニフェストの設定が必要です

適している対象

  • バックグラウンドタスクの信頼性を必要とするアプリ
  • 位置ベースのサービス
  • メディアプレーヤー
  • IoTデバイスコントローラー
  • リアルタイムデータ同期

注意事項

  • iOS 対応なし
  • 古いAndroidバージョンでのテストが限定的です
  • Androidマニフェストの設定が必要です
  • フォアグラウンドサービスの通知が必要です
  • バッテリー使用の影響

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

foreground_service (Flutter v.1.12.x or later)

Create Android foreground service/notification

Prep (Android side):

Android foreground services require a notification to be displayed,
and notifications require an icon.

For this plugin to work, the icon needs to be in this specific location:

res/drawable/org_thebus_foregroundserviceplugin_notificationicon

(take a look at the /example app if you're confused)


-- NOTE FOR PLUGIN VERSION 2.0.0 and above --
compileSdkVersion & targetSdkVersion need to be 29 or above, or the build will fail
these values are set/can be changed in the build.gradle for the app

Use (Flutter/Dart side):

To start the service, call ForegroundService.startForegroundService([serviceFunction])

serviceFunction will then be executed periodically, but "minimum/best-effort"
i.e. it will try to make the interval between function executions *at least* that long

Doesn't work?

As long as you're calling ForegroundService.startForegroundService,
"flutter run" should show error messages that indicate what's wrong/missing

i.e. messages beginning with E/ForegroundServicePlugin indicate an error from the plugin

Caution:

ForegroundService.notification.get* methods may give unexpected values.

Once notifications are sent out, there's no way to retrieve the "current" data.

To work around this, the plugin keeps a version of the notification around.
This version may not have been "sent out" yet, however.

Disclaimer:

Most of the fancy stuff is shamelessly pilfered from the android_alarm_manager plugin

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。