Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin accessing constant in inner class from Java

Tags:

android

kotlin

NOTE: This issue has been resolved since Kotlin 1.0 beta version (at least). Keeping the rest of the contents intact for historical reason.


I'm using Kotlin with Android and I'm trying to use some constants from the SDK, like this one:

MediaRecorder.AudioSource.MIC;

It doesn't see AudioSource, so it doesn't see the MIC as well. I've tried changing the imports, cleaning the project. Nothing worked so far. I've temporarily solved it by importing it in a Java class, which worked just fine, and then I just refer to my Java class from my Kotlin file,but I would really like to know why this happens and how I can avoid having that Java class.

like image 819
pedronveloso Avatar asked Apr 29 '26 06:04

pedronveloso


1 Answers

I can confirm, accessing MediaRecorder.AudioSource.MIC doesn't work. However, if you import android.media.MediaRecorder.AudioSource manually, you can access AudioSource.MIC.

like image 164
Kirill Rakhman Avatar answered Apr 30 '26 20:04

Kirill Rakhman