코틀린 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)이라고 오류가 떠요.
해결방법을 모르겠습니다..
댓글 입력