Moh*_*ara 6 java android android-jobscheduler
我正在关注视频JobScheduler:
https://www.youtube.com/watch?v=XFN3MrnNhZA
但是lint给了我那context.getSystemService(class)是api 23.因为我错过了一些东西或者是否有机器人用api改变了什么?
注意:大多数人想知道是否JobScheduler介绍了api 21如何在没有它的情况下工作getSystemService(Class)
谢谢.
Moh*_*ara 10
感谢Reghunandan我使用以下方法找到了更好的解决方案:
github.com/firebase/firebase-jobdispatcher-android
但如果有任何身体在这里遇到同样的问题是错误:
getSystemService(Class) API 23
Run Code Online (Sandbox Code Playgroud)
应该:
getSystemService(String) API 1
getSystemService(context.JOB_SCHEDULER_SERVICE) API 21
Run Code Online (Sandbox Code Playgroud)
小智 6
来到这里,NotificationManager 也遇到了类似的问题。我最终做的是
val notificationManager =
ContextCompat.getSystemService(
requireContext(),
NotificationManager::class.java
) as NotificationManager
Run Code Online (Sandbox Code Playgroud)