felHR85 / UsbSerial

Usb serial controller for Android
MIT License
1.81k stars 589 forks source link

Non-static method write(byte[]) cannot be referenced from a static context #306

Closed lhtrevisan closed 4 years ago

lhtrevisan commented 4 years ago

Hi! First of all, I'm sorry if that's a dumb question, but i'm new to java and Android Studio. My app uses the Master/Detail template and I'm getting the error "Non-static method write(byte[]) cannot be referenced from a static context" when trying to write data to serial from any activity. Is there a way to use the library with this template? What may I be dong wrong?

lhtrevisan commented 4 years ago

Solved by converting the code to Kotlin, then following the Kotlin 101 tutorial and using the function (activity as ItemListActivity).m_serial?.write(input.toByteArray())

Please, close the Issue.