Lord, please tell me. Do I have to do:

mInputStream.close(); mOutputStream.close(); 

After obtaining the necessary data. If you do not close, what is the danger?

And another question, Thread runs cyclically in RepeatingAlarmService - if not stopped at the end of the class (after receiving data) like this:

 mReadThread.interrupt(); 

then in the next RepeatingAlarmService loop occurs:

 mReadThread = new ReadThread(); mReadThread.start(); 

start a new thread or he understands that the thread is already running and ignores the launch of a new Thread?

    1 answer 1

    It is not necessary to close. But if you do not close, it threatens with a memory leak, and performance problems (as it will constantly hang and consume resources). Regarding the second, he will launch a new stream.

    • Tell me, but this will fix the situation: if (mReadThread == null) {mReadThread = new ReadThread (); mReadThread.start (); } - Incognito