相关疑难解决方法(0)

如何创建在应用程序关闭时也能工作的 Flutter 后台服务

我正在为大学的学术目的开发 Flutter 应用程序。现在,我需要运行一种“永远在线”的后台服务,以便使用蓝牙,最重要的是从外部 REST API 获取定期更新。

我已经从 pub.dev (thisthis)检查了这两个库,但没有找到开箱即用的完美解决方案(如预期的......)。我还看到了 Kotlin 原生的东西(这里)。我想知道的是实现我的目标的最佳选择是什么(在最佳实践、完整性和简单性方面)。

查看下图以获得更多示意图:

在此处输入图片说明

rest service android background-process flutter

15
推荐指数
3
解决办法
2万
查看次数

如何在Flutter中创建服务以使应用始终在后台运行?

我想使Flutter应用程序始终在后台运行。使用android,我们必须创建一个始终在后台运行的服务。在Flutter文档中找不到关于服务的任何信息。

Flutter可以做这种事情吗?

service dart flutter

11
推荐指数
4
解决办法
2万
查看次数

重启设备后调用flutter中的方法

我构建了一个待办事项列表应用程序,该应用程序应该显示通知以提醒任务。为了能够将通知安排在截止日期的准确时间,我将通知数据从 flutter 传递到 kotlin,并显示来自广播接收器的通知。

这里我将通知数据发送到 kotlin:

 await platform.invokeMethod('setNextNotification', {
      'tasksNames': tasksNames,
      'notificationsTimeInMillis': notificationsTimeInMillis
    });
Run Code Online (Sandbox Code Playgroud)

这就是我在 FlutterActivity 中获取数据的方式:

private const val CHANNEL = "flutter.native/helper"

class MainActivity : FlutterActivity() {

companion object {
    const val TASKS_NAMES_EXTRA = "tasksNames"
    const val NOTIFICATIONS_TIME_IN_MILLIS_EXTRA = "notificationsTimeInMillis"

}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    GeneratedPluginRegistrant.registerWith(this)

    // Init the AlarmManager.
    val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager

    // We got here from the setNotifications() method in flutter...
    MethodChannel(flutterView, CHANNEL).setMethodCallHandler { call, result ->
        if (call.method == "setNextNotification") { …
Run Code Online (Sandbox Code Playgroud)

dart flutter

7
推荐指数
1
解决办法
1683
查看次数

Flutter:将应用程序作为后台服务运行

我想在用户断开手机通话时显示自定义弹出消息。问题是如何检测应用程序何时未运行。任何线索都会有所帮助。

flutter

6
推荐指数
1
解决办法
7666
查看次数

标签 统计

flutter ×4

dart ×2

service ×2

android ×1

background-process ×1

rest ×1