我怎么能每天早上运行一个任务,即使手机重新启动之前在Xamarin(pref. Android和IOS)使用例如闪亮?

lc8prwob  于 9个月前  发布在  Android
关注(0)|答案(1)|浏览(133)

我有两个接口:

  • 议程:一个界面,以获得我的一天的ICal。
  • Spotify:Spotify API的C#接口。

我想在早上运行一个任务,它会检查我当天的第一个约会。然后它应该安排一个任务在约会前1.5小时运行。这个任务将调用Spotify功能,就像闹钟一样。
有没有人知道这是如何实现的,至少Android?
感谢您提前回复!
我尝试使用BroadcastReceiver with Booting来连续运行一个任务,但我认为这不是一个有效的解决方案。
我试着研究Shiny,但我仍然不明白背景和时钟系统的Android原理

yk9xbfzb

yk9xbfzb1#

您需要的可能是后台服务
安卓系统:https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/services/foreground-services
IOS:https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-techniques/
关于Android的步骤:
1.在android manifest中激活android.permission. FOREESTION_SERVICE
1.创建执行Spotify操作的Intent Service:https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/services/creating-a-service/intent-services
1.使用android上下文,你可以在任何你想要的地方运行StartForeGroundService(yourIntent)。
您也可以将您的操作 Package 在通知中,如本例所示:https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/services/foreground-services
在接下来的几天里,我将创建一个样本,并张贴在那里的链接,但我希望它能帮助你现在。

相关问题