安卓工作室 在特定时间安排一个方法

huangapple 未分类评论47阅读模式
英文:

Androd Studio Schedule a method at specific time

问题

我正在使用Android Studio - Java进行工作。
在过去的两天里,我进行了大量搜索,但没有找到答案。
我想安排一个方法只运行一次,即使应用程序被关闭或手机被锁定。
我尝试过使用Alarm Manager,但当我关闭应用程序时它不起作用。
我尝试了JobScheduler,但它需要互联网,而我的方法不需要互联网。
我尝试创建了一个后台服务,但我不知道如何在X时间后调用停止方法,并在服务停止时调用我想要的方法。
X时间 - 用户使用时间选择器选择要安排的时间,当时间到达时,我想要执行我的方法。
请问有人可以帮帮我吗?

英文:

I'm working with android studio - java.
In the last two days i have searched a lot and didn't find an answer.
I want to schedule a method once time, even if the app is closed or phone is locked.
I have tried with Alarm manager and it doesn't work when i close the app.
I tried JobScheduler and it requires Internet, my method doesn't requires Internet.
I tried to create a background service but i don't know how to call the stop method after X time and when the service stops call the method i want.
X time - the user pick a time to schedule with timepicker and when it finish i want to execute my method.
Please can someone help me?

huangapple
  • 本文由 发表于 2020年7月24日 00:59:58
  • 转载请务必保留本文链接:https://java.coder-hub.com/63059465.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定