我用了CH340usb轉(zhuǎn)串口芯片連接安卓的otg手機(jī),在安卓系統(tǒng)上使用了CH34xUart_Android 這個庫文件接口,現(xiàn)在我能使用里面的UsbFeatureSupported和SetTimeOut函數(shù),但是用到EnumerateDevice或ResumeUsbList時,系統(tǒng)就會報錯:
java.lang.RuntimeException:Can't create handle inside thread that has not called Looper.prepare()
我用的編程軟件是C++ Builder XE10,我是在程序的按鈕事件中調(diào)用的EnumerateDevice,應(yīng)該是沒錯的吧,另外,我實例化CH34xUARTDriver的方法是:
??_di_JCH34xUARTDriver CH34xUARTDriver1 = TJCH34xUARTDriver::JavaClass->init(JUsbManager1,MainActivity()->getApplicationContext(),StringToJString(ACTION_USB_PERMISSION));
上面的錯誤不知這是什么原因引起的,有知道的人能指點下嗎,懇請相助...