Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的服务类中有一个用于 android 应用程序的 AtomicBoolean。我想监视该变量,如果值为 false,它会关闭媒体播放器,如果值为 true,则让它继续运行。我应该在哪个生命周期方法中进行此测试 while 循环?
如果要监视,则需要在类的onStartCommand()方法中设置一个循环计时器Service。请记住,这会让您有责任在工作完成后停止服务。
onStartCommand()
Service