一、在Activity下声明Intent,居然提示”Accidental override: The following declarations have the same JVM signature”
图片
解释:说的是超类中已经声明了这个intent,所以只要将intent这个对象名重命名即可。
private val intentService: Intent? = null
二、声明ServiceConnected的方法
private val conn = object : ServiceConnection {
//绑定服务,回调onBind()方法
@SuppressLint("WrongConstant")
override fun onServiceConnected(name: ComponentName, service: IBinder) {
myAidl= IMyAidlInterface.Stub.asInterface(service)
Toast.makeText(this@MainActivity, myAidl!!.add(4,5).toString(),Toast.LENGTH_LONG).show()
}
override fun onServiceDisconnected(name: ComponentName) {
myAidl = null
}
}