如何在Flutter中安排特定时间的警报?

编程入门 行业动态 更新时间:2024-10-26 03:39:01
本文介绍了如何在Flutter中安排特定时间的警报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Flutter项目中,我想将警报安排在一天的特定时间,或者只在该特定时间触发手机中的内置警报。

为此,我集成了Flutter的一个插件-

这里有一些可能有用的有用软件包:

  • 要连续运行后台进程,请查看以下软件包: pub.dev/packages/background_fetch

  • 从后台进程播放声音: flutter.dev/docs/development/packages-and-plugins/background-processes

  • 如果需要显示计划的消息,请使用本地通知: pub.dev/packages/flutter_local_notifications

In my Flutter project, I want to schedule an alarm on a specific time of a day or just trigger the built in alarm in my phone on that particular time.

For that purpose, I have integrated one plugin from Flutter -

pub.dev/packages/android_alarm_manager#-example-tab-

And then I followed exactly the example given in that documentation and added all the permissions in Android Manifest file.

After running this project it shows like below-

It is showing one button to shot one alarm but it is just updating the text. Nothing like any alarm is set as I wanted and I am not getting what's going on in this project.

So, I need a solution that- what changes I need to do get that alarm working on a fixed time scheduled by me and it should work from background as I want this alarm to work when I remove it from memory too. Any example code sample, full documentation or project sample will be helpful for this question.

解决方案

You need to use some things together. You need to run a background process and start to play a sound from there. I suggest you to take a deep look at the flutter docs about the subject: flutter.dev/docs/development/packages-and-plugins/background-processes

Here are some useful packages that might help:

  • To run background processes continuously, take a look at this package: pub.dev/packages/background_fetch

  • To play a sound from background processes: flutter.dev/docs/development/packages-and-plugins/background-processes

  • If you need to show scheduled messages, use local notifications: pub.dev/packages/flutter_local_notifications

更多推荐

如何在Flutter中安排特定时间的警报?

本文发布于:2023-11-27 05:25:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636779.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   时间   如何在   Flutter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!