1. 程式人生 > >Android 之Kotlin開發 不懂搞搞

Android 之Kotlin開發 不懂搞搞

一、在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 } }