코틀린 AsyncTask의 doInBackground()에서 진동울리게하는 방법

조회수 394회

class SocketCameraActivity(var page: String, var oBtn: ImageButton, var cBtn: ImageButton) : AsyncTask() { override fun doInBackground(vararg params: Void?): String? { ... val vibrator = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { vibrator.vibrate( VibrationEffect.createOneShot( 1000, VibrationEffect.DEFAULT_AMPLITUDE ) ) } else { vibrator.vibrate(1000) } ... } }

이런식으로 적었는데 getSystemService(Context.VIBRATOR_SERVICE)에 빨간불이 뜨고, Type inference failed: fun getSystemService(context: Context, serviceClass: Class):T? cannot be applied to ( String)이라고 오류가 떠요.

해결방법을 모르겠습니다..

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)