On Apr 10, 11:10 am, Neurobe <[email protected]> wrote:
> Anyone out there manage to get this library ro work half-way decent?? [I
> want my money back.]
Actually I did get it working quite well. There were a few things I
had to figure out on my own. In particular:
The SlickUSB2Serial example code is set up for a single activity life-
cycle. It does not make any provisions for real-world applications
that need pause and resume activities all the time. To get the
SlickUSB2Serial library to work well with multiple pauses and resumes
I did a
SlickUSB2Serial.initialize(this);
In my onCreate, and in onDestroy I did
SlickUSB2Serial.cleanup(this);
autoconnectIssued = false;
Then in onResume I did:
if(!autoconnectIssued)
{
autoconnectIssued = true;
SlickUSB2Serial.autoConnect(this);
}
where autoconnectIssued is a static boolean meant to prevent issuing
multiple autoConnects while the first one is still pending. I don't
know why but without this precaution autoConnect was being issused
twice and the second call was failing. Then in onPause I did
if(mSelectedAdapter != null)
{
SlickUSB2Serial.cleanup(this);
SlickUSB2Serial.initialize(this);
mSelectedAdapter = null;
autoconnectIssued = false;
}
The rest of my code was like the SlickUSB2Serial sample code. As you
can see I bring the entire serial connection to a close every time the
activity pauses, and start it up when the activity resumes. I realize
that this may not be optimal for some applications where it would be
nice to have serial comm going on in the background while some other
activity it active. But the SlickUSB2Serial library functions
require association with an activity, so I didn't find a way to start
it up and have it run continuously for the life of the app. But for
my application that was OK because the serial comm was only used when
a certain activity was active. I hope this helps.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en