I have an issue that seems to persist about 70% of the time - my USB Thread's handler is not called in a looper.
In run() I have
//Sends messages to usb accessory
Looper.prepare();
controlSender = new Handler() {
@Override
public void handleMessage(Message msg) {
try{
Log.d("USB Thread", "Writing out to USB filestream");
output.write((byte[])msg.obj);
}catch(final Exception e){
Log.d("USB Thread", "Writing to USB filestream failed");
e.printStackTrace();
UIHandler.post(new Runnable() {
@Override
public void run() {
onNotify("USB Send Failed " + e.toString() + "\n");
}
});
}
}
};
Looper.loop();
Neither Log is ever called when this problem happens, and messages are being received on this thread as well (might be an issue?). this.start();
is called whenever the accessory is connected, and I call constrolSender.getLooper().quit();
whenever it's disconnected.