Package com.dsi.ant
Class AntService
java.lang.Object
com.dsi.ant.AntService
This is the starting point for using the ANT API, by calling
bindService()
you allow communication with the
ANT Radio Service.
This class provides the interface that applications use to request connections to various components of the ANT Radio Service. Unlike standard system services which are always running, the ANT Radio Service will preserve resources by only running while an application is bound to it. For this reason you must stay bound with the ANT Radio Service at all times you are using a component.
Currently available components are:
- Since:
- 4.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Use this as the action parameter of a binding intent get a service interface back which can be wrapped by anAntService
object.static final int
The value returned bygetVersionCode(Context)
if ANT Radio Service is not installed.static final int
The value returned bygetVersionCode(Context)
if ANT Radio Service is unknown. -
Constructor Summary
ConstructorsConstructorDescriptionAntService
(android.os.IBinder binder) Creates a newAntService
using the binding obtained frombindService(android.content.Context, android.content.ServiceConnection)
to communicate with the ANT Radio service. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
bindService
(android.content.Context bindContext, android.content.ServiceConnection conn) Connect to the ANT Radio Service, creating it if needed.static void
displayAntSettings
(android.content.Context context) Starts the ANT settings system settings activity.Provides a connection to the Adapter Provider component in the ANT Radio Service.Provides a connection to the Channel Provider component in the ANT Radio Service.static int
getVersionCode
(android.content.Context context) Gets the version code for ANT Radio Service.static String
getVersionName
(android.content.Context context) Gets the version name for ANT Radio Service.static boolean
Used internally by the ANT API.static boolean
Used internally by the ANT API.static boolean
Used internally by the ANT API.static boolean
Used internally by the ANT API.static boolean
Used internally by the ANT API.
-
Field Details
-
ACTION_BIND_ANT_RADIO_SERVICE
Use this as the action parameter of a binding intent get a service interface back which can be wrapped by anAntService
object.- Since:
- 4.0
- See Also:
-
SERVICE_VERSION_CODE_NOT_YET_KNOWN
public static final int SERVICE_VERSION_CODE_NOT_YET_KNOWNThe value returned bygetVersionCode(Context)
if ANT Radio Service is unknown.- Since:
- 4.7.3
- See Also:
-
SERVICE_VERSION_CODE_NOT_INSTALLED
public static final int SERVICE_VERSION_CODE_NOT_INSTALLEDThe value returned bygetVersionCode(Context)
if ANT Radio Service is not installed.- Since:
- 4.1
- See Also:
-
-
Constructor Details
-
AntService
public AntService(android.os.IBinder binder) Creates a newAntService
using the binding obtained frombindService(android.content.Context, android.content.ServiceConnection)
to communicate with the ANT Radio service. This binding should be acquired by usingACTION_BIND_ANT_RADIO_SERVICE
- Parameters:
binder
- The service binding used to talk to the ANT Radio service.- Since:
- 4.0
-
-
Method Details
-
requiresBundle
public static boolean requiresBundle()Used internally by the ANT API. Checks if the installed version of the ANT Radio Service expects a bundle with extra data.- Returns:
- True if parcels must include a bundle.
- Since:
- 4.1
-
hasAdapterWideConfigurationSupport
public static boolean hasAdapterWideConfigurationSupport()Used internally by the ANT API. Checks if the installed version of the ANT Radio Service has support for adapter wide configuration.- Returns:
- True if there is support for adapter wide configuration, False if not supported or service is not bound.
- Since:
- 4.1
-
hasContinuousScanSupport
public static boolean hasContinuousScanSupport()Used internally by the ANT API. Checks if the installed version of the ANT Radio Service has support for continuous scan.- Returns:
- True if there is support for continuous scan.
- Since:
- 4.11.1
-
hasAdapterProviderSupport
public static boolean hasAdapterProviderSupport()Used internally by the ANT API. Checks if the installed version of the ANT Radio Service has support for adapter provider.- Returns:
- True if there is support for adapter provider.
- Since:
- 4.7.2
-
hasFastChannelInitiation
public static boolean hasFastChannelInitiation()Used internally by the ANT API. Checks if the installed version of the ANT Radio Service has support for fast channel initiation.- Returns:
- True if the installed ANT Radio Service supports fast channel initiation.
- Since:
- 4.12.12
-
bindService
public static boolean bindService(android.content.Context bindContext, android.content.ServiceConnection conn) Connect to the ANT Radio Service, creating it if needed. The function should be used in the same manner as a standard AndroidContext.bindService(Intent, ServiceConnection, int)
call except it automatically handles the intent and flags parameters. This defines a dependency between your application and the ANT Radio Service. The given conn will receive the service object when it is created and be told if it dies and restarts. The ANT Radio Service will be considered required by the system only for as long as bindContext exists. For example, if this Context is an Activity that is stopped, the ANT Radio Service will not be required to continue running until the Activity is resumed.This function will throw
SecurityException
if you do not have permission to bind to the ANT Radio Service.- Parameters:
bindContext
- The context used to perform the bindconn
- The service connection to receive the binder- Returns:
- If you have successfully bound to the service, true is returned; false is returned if the connection is not made so you will not receive the service object.
- Throws:
SecurityException
- if you do not have permission to bind to the ANT Radio Service- Since:
- 4.0
- See Also:
-
Context.unbindService(ServiceConnection)
-
getChannelProvider
Provides a connection to the Channel Provider component in the ANT Radio Service. Only requests the remote connection the first time, then returns a cached copy.- Returns:
- A Channel Provider you may acquire ANT Channels from.
- Throws:
android.os.RemoteException
- if the remote service has died.- Since:
- 4.0
-
getAdapterProvider
public AntAdapterProvider getAdapterProvider() throws android.os.RemoteException, UnsupportedFeatureExceptionProvides a connection to the Adapter Provider component in the ANT Radio Service. Only requests the remote connection the first time, then returns a cached copy.- Returns:
- An Adapter Provider you may obtain hardware information from.
- Throws:
android.os.RemoteException
- if the remote service has died.UnsupportedFeatureException
- if feature is not supported by the installed ANT Radio Service.- Since:
- 4.7.2
-
getVersionCode
public static int getVersionCode(android.content.Context context) Gets the version code for ANT Radio Service.- Parameters:
context
- The current context.- Returns:
- If the context is null and the service has not yet been bound
returns
SERVICE_VERSION_CODE_NOT_YET_KNOWN
. Otherwise, it returns the version code of the ANT Radio Service, or if the service package name does not exist in the android package info returnsSERVICE_VERSION_CODE_NOT_INSTALLED
. - Since:
- 4.1
-
getVersionName
Gets the version name for ANT Radio Service.- Parameters:
context
- The current context.- Returns:
- If the context is null and the service has not yet been bound
returns
SERVICE_VERSION_NAME_NOT_YET_KNOWN
. Otherwise, it returns the version name of the ANT Radio Service, or if the service package name does not exist in the android package info returnsSERVICE_VERSION_NAME_NOT_INSTALLED
. - Since:
- 4.1
-
displayAntSettings
public static void displayAntSettings(android.content.Context context) Starts the ANT settings system settings activity.- Parameters:
context
- The current context- Throws:
android.content.ActivityNotFoundException
- on Android devices that do not have the ANT Android system settings built in to their firmware- Since:
- 4.8.1
-