I am new to Kotlin and I have an error like this in my onActivityResult
method
'Type mismatch: inferred type is Intent? but Intent was expected'
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode != REQUEST_CODE)
{
return
}
if (resultCode != Activity.RESULT_OK)
{
Toast.makeText(this,"Screen cast permission denied",Toast.LENGTH_LONG).show()
return
}
mediaProjectionCallBack = MediaProjectionCallback()
mediaProjection = projectionManager!!.getMediaProjection(resultCode,data)
mediaProjection!!.registerCallback(mediaProjectionCallBack,null)
virtualDisplay = createVirtualDisplay()
mediaRecorder!!.start()
}
Error is in this line when I use data from onActivity
result it gives me an error which I mentioned above:
mediaProjection = projectionManager!!.getMediaProjection(resultCode,data)