Hi Rohan,
Thanks a lot for your timely reply.
>> You should acquire a partial wake lock from the PowerManager if the user of your app is on a device which suspends the USB on screen off.
Yes, I am already using wake lock as follows:
((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "TAG").acquire();
However, in practice what is happening is, some users of the service is pressing the hard button to keep Tablet to sleep. So the above code is not quite helping.
>> . I can run an application that is using ANT, and after connecting an ANT USB stick make neither the ANT Radio Service or ANT USB Service show as 'in use' by the app in Settings - although the ANT connection is still working fine.
Kindly allow me to reiterate my observations, When I connect the USB stick, both the services are started and works like a charm, ANT+ devices are communicated to Android application, quite normal.
During this phase, when you go to Settings -> APPS -> Running, here are the state of the ANT Radio+Usb Services:
ANT Radio Service, 2 processes and 1 Service
ANT USB Service, running.
One more observation, Settings -> APPS, select each of the Services, you have "Force Stop" button active indicating the service is running....
Then what happens when the screen goes blank, after a period of time out.... Here is the state of each of the ANT radio + usb services:
ANT Radio Service, still works, with 1 Service and 1 Process.
ANT USB Service, still indicates running...
Which means, Settings -> APPS, select each of the Services, you have "Force Stop" button active indicating the both service is running....
Here is what I believe ANT Radio Service, is not recognizing ANT USB Service any more. If I manually force stop the ANT USB Service, and programmatic when I stop and start the ANT Radio Service. then every things works great!!
>> If the USB has been suspended, then your channel configuration would have been lost. An attempt to open the channel will result in a Channel In Wrong State response as you must assign and reconfigure again.
Actually I am assigning and reconfiguration the Channel for each attempt. I sincerely believe the above state is not recoverable, unless you do one of the following two:
1) Unplug the OTG cable (USB Stick) and reconnect it.
2) Force stop ANT USB Service.
>> The ANT USB Service will run only while the ANT Radio Service is running. Anytime you connect an ANT USB Stick an activity is automatically started to get the user permissions for the ANT USB Service to use the stick, but that activity is stopped immediately after the user responds.
So is there any way to Force Stop the ANT USB Service programatically? Using Context.stopservice(Intent) API call?
Much appreciate your active engagement in helping solve the problem.
Ram