Hi,
i have been working in a app that allow comunicate with a open
accesory dev kit, and i have a big throuble, when ended the USB
comunication I cant start new one until the readthread die. then when
the ativity is pasused or throw new activity i cant comunicate with an
accessory.

i close the parcelFileDescriptor, inputStream and outputStream in the
onPause method and try to open again in the onResume method unless
that the readthread dies. i used a flat to stop the thread. some thing
like this

public void run() {
                // TODO Auto-generated method stub
                byte[] buffer = new byte[1024];  // buffer para leer el
stream
                int bytes; // numero de bytes retornado de read()
        while(continueRunning) {
                        try {

                                bytes = inputStream.read(buffer);

                                byte[] data = new byte[bytes];
                                System.arraycopy(buffer, 0, data, 0, bytes);

                                synchronized(readData) {
                                        readData.add(data);
                                }

                                handler.obtainMessage(what, bytes, -1, new
USBMensaje(USBMensaje.MessageType.READ,
data)).sendToTarget();
                        } catch (IOException e) {
                                //Exiting read thread
                                break;
                        }

                }

but the thread not always dies, and i dont have control when the app
could connect

Hope anybody could help me to fix this issue.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to