java.lang.IllegalArgumentException:计划服务android.permission.BIND\u作业\u服务权限
我想运行JobIntentService,但出现了此错误java.lang.IllegalArgumentException:计划服务android.permission.BIND\u作业\u服务权限,android,android-service,Android,Android Service,我想运行JobIntentService,但出现了此错误 java.lang.IllegalArgumentException: Scheduled service ComponentInfo{MyIntentService} does not require android.permission.BIND_JOB_SERVICE permission 有人能帮我吗 我试过这个 但这没用 class MyIntentService : JobIntentService() { @R
java.lang.IllegalArgumentException: Scheduled service ComponentInfo{MyIntentService}
does not require android.permission.BIND_JOB_SERVICE permission
有人能帮我吗
我试过这个
但这没用
class MyIntentService : JobIntentService() {
@RequiresApi(Build.VERSION_CODES.O)
override fun onHandleWork(intent: Intent) {
val CHANNEL_ID = "my_channel_01"
val channel = NotificationChannel(
CHANNEL_ID,
"Channel human readable title",
NotificationManager.IMPORTANCE_DEFAULT
)
(getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).createNotificationChannel(
channel
)
val notification = Builder(this, CHANNEL_ID)
.setContentTitle("adf")
.setSmallIcon(R.drawable.ic_baseline_settings_input_component_24)
.setBadgeIconType(NotificationCompat.BADGE_ICON_SMALL)
.setSmallIcon(R.drawable.ic_baseline_settings_input_component_24,2)
.setContentText("ewr").build()
startForeground(1, notification)
try {
for (x in 1..10){
Thread.sleep(1000)
Log.d("Nurs", "sleep $x")
}
} catch (e: InterruptedException) {
// Restore interrupt status.
Thread.currentThread().interrupt()
}
}
internal fun enqueueWork(context: Context?, work: Intent?) {
enqueueWork(context!!, MyIntentService::class.java, RSS_JOB_ID, work!!)
}
}
在main活动中,我调用:
val mIntent = Intent(this, MyIntentService::class.java);
mIntent.putExtra("maxCountValue", 1000)
enqueueWork(this, MyIntentService::class.java,
Companion.RSS_JOB_ID, mIntent)
将
android:permission=“android.permission.BIND_JOB_SERVICE”
添加到作业服务的
元素中:
<service
android:name=".WorkService"
android:permission="android.permission.BIND_JOB_SERVICE" />
(from)我做了,但没有help@Nurseyit:您可以下载示例项目并进行实验。或者,您可以使用更新您的问题,包括您当前拥有的任何错误消息(如果您添加了该权限,将不再是您在问题中引用的错误消息)。我面临着相同的问题。。有什么帮助吗?在我的案例中,我使用的是JobIntentService类……如果我尝试使用JobSchecular,它会起作用,我不知道,试着查看示例项目,@CommosWare Recommended我已经看过了,但在该示例中,使用的是JobService,我使用的是JobIntentService