IntentService无法调用enqueueWork()

问题描述 投票:0回答:1

我想将一些信息传递给我的IntentService来启动它。我在官方文档中做了所有事情,但我不能调用enqueueWork()。

这是我的代码:

  viewHolder.TrackImage.setOnClickListener {
            val TUrl = TrackURL[position]
            val TName = TName[position]
            val TArtist = TArtist[position]
            val TImage = TImage[position]
            val TDuration = TDuration[position]

            val a = Intent().apply { putExtra("TUrl", TUrl) }
            val b = Intent().apply { putExtra("TArtist", TArtist) }
            val C = Intent().apply { putExtra("TName", TName) }
            val d = Intent().apply { putExtra("TImage", TImage) }
            val e = Intent().apply { putExtra("TDuration", TDuration) }
            MpService.enqueueWork(c, MpService::class.java, MpS_JOB_ID, a,b,C,d,e)
  }

EnqueueWork是红色的,它不会以某种方式被识别。知道为什么吗?

android kotlin
1个回答
0
投票

enqueueWork()a function on JobIntentService。它不是IntentService的功能。

要启动IntentService,请使用标识服务的startService()调用Intent。或者,在许多情况下,更好的答案是切换到JobIntentService

© www.soinside.com 2019 - 2024. All rights reserved.