Example of how to start a background USB accessory service on Android
Created GitHub repo. (via)
I've hacked around a working implementation of this (see), so now going to do it "properly".
Created a new Eclipse Android project BackgroundUsbAccessory (it's got a bunch of resources we don't currently need but that's okay). (via)
Now committed the more "proper" implementation: https://github.com/follower/android-background-service-usb-accessory/tree/00b2f0dbedfcce01c162e7c1f6574c32f309e351
It displays a notification when the USB accessory is attached, then waits for detachment and finally cleans up after itself.
Link about communicating with Android USB accessory.
Have now got it successfully sending bytes from the service to an Arduino which then displays the bytes on an LCD. Not commited all the code yet but there is some more up there.
Pushed the current demo to the repository--displays the current time on an LCD or serial output: https://github.com/follower/android-background-service-usb-accessory/tree/e7fc2a05473a0e88bbff713db151bf235b25cf50
Switched to using a queue of the text to be displayed.
Merged in Android SMS notification code so now the demo will also display the (name or phone number) of the sender and start of message on the display in addition to the current time.
Pushed current demo code to the repository: https://github.com/follower/android-background-service-usb-accessory/tree/0556c990e38b2f12c508130aae4dca7223b85bde
Ideally the screen display code would be a service which other activities would connect to rather than having the time/sms info be part of the background service--but it works for now...