net.rim.blackberry.api.accessory
Class AccessoryManager

java.lang.Object
  extended by net.rim.blackberry.api.accessory.AccessoryManager

public abstract class AccessoryManager
extends Object

Manages the associations of accessories and applications.

In order for an application to be started when an accessory attached, the application must do one of two things:

  1. Register against a type of accessory
  2. Register its application identifier

When applications are started by the, a Behavior Global Event is broadcasted as a global event. In this way, applications will know why they were started and can perform application specific features based on this context.

If multiple applications are associated with the same accessory type or accessory GUID, then users may be provided a choice.

Registering against a type of accessory

The types are defined by the Accessory.TYPE_* constants in this class.
accessoryManager.registerApplication( Accessory.TYPE_CHARGER, ApplicationDescriptor.currentApplicationDescriptor() );

Registering an application identifier

The application has an identifier that the related accessory knows about. Registering the application id and the application maps the accessory to the application.
accessoryManager.registerApplication( "app id 1234", ApplicationDescriptor.currentApplicationDescriptor() );

See Also:
net.rim.blackberry.api.behavior.BehaviorGlobalEvent}, net.rim.blackberry.api.accessory.Accessory}, net.rim.device.api.system.ApplicationManager}
Since:
BlackBerry API 7.0.0

Method Summary
static AccessoryManager getAccessoryManager()
          Returns an Accessory Manager instance.
abstract  Accessory getConnectedAccessory()
          Returns the currently connected accessory.
abstract  boolean isApplicationRegistered(int accessoryType)
          Checks if an application is already registered for the given accessory type.
abstract  boolean isApplicationRegistered(String appId)
          Checks if an application is already registered for the given accessory guid.
abstract  void registerApplication(int accessoryType, ApplicationDescriptor appDescriptor)
          Registers an application to start for a given accessory type.
abstract  void registerApplication(String applicationId, ApplicationDescriptor appDescriptor)
          Register against an application identifier so that an accessory with a matching application identifier will start the given application.
abstract  void unregisterApplication(int accessoryType, ApplicationDescriptor appDescriptor)
          Unregisters an application against an accessory type.
abstract  void unregisterApplication(String appId, ApplicationDescriptor appDescriptor)
          Unregisters an application against an application ID.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Method Detail

getAccessoryManager

public static AccessoryManager getAccessoryManager()
Returns an Accessory Manager instance.

Returns:
an Accessory Manager instance.
Since:
BlackBerry API 7.0.0

registerApplication

public abstract void registerApplication(String applicationId,
                                         ApplicationDescriptor appDescriptor)
Register against an application identifier so that an accessory with a matching application identifier will start the given application.

Each time an accessory with the given app id is attached, then the given application will launch automatically.

If an application is already registered against the given app id, then the given application will replace it.

Parameters:
applicationId - a globally unique identifier of the accessory.
appDescriptor - a non-null application descriptor
Throws:
NullPointerException - if applicationId or appDescriptor is null
Since:
BlackBerry API 7.0.0

registerApplication

public abstract void registerApplication(int accessoryType,
                                         ApplicationDescriptor appDescriptor)
Registers an application to start for a given accessory type.

If an application is already registered against the given accessory type, then the given application will replace it.

Parameters:
accessoryType - one of the TYPE_* constants defined in this class.
appDescriptor - a non null application descriptor
Throws:
NullPointerException - if appDescriptor is null
Since:
BlackBerry API 7.0.0

unregisterApplication

public abstract void unregisterApplication(String appId,
                                           ApplicationDescriptor appDescriptor)
Unregisters an application against an application ID.

Parameters:
appId - a non-null unique identifier of an application;
appDescriptor - a non-null application descriptor
Throws:
NullPointerException - if guid or appDescriptor is null.
Since:
BlackBerry API 7.0.0

unregisterApplication

public abstract void unregisterApplication(int accessoryType,
                                           ApplicationDescriptor appDescriptor)
Unregisters an application against an accessory type.

Parameters:
accessoryType - one of the TYPE_* constants defined in this class.
appDescriptor - a non null application descriptor
Throws:
NullPointerException - if appDescriptor is null
IllegalArgumentException - if accessoryType is invalid.
Since:
BlackBerry API 7.0.0

getConnectedAccessory

public abstract Accessory getConnectedAccessory()
Returns the currently connected accessory.

Returns:
The currently connected accessory or null if nothing is connected.
Since:
BlackBerry API 7.0.0

isApplicationRegistered

public abstract boolean isApplicationRegistered(int accessoryType)
Checks if an application is already registered for the given accessory type.

Parameters:
accessoryType - an accessory type to check
Returns:
true if and only if some application is registered for the given accessory type.
Since:
BlackBerry API 7.0.0

isApplicationRegistered

public abstract boolean isApplicationRegistered(String appId)
Checks if an application is already registered for the given accessory guid.

Parameters:
appId - a non-null unique identifier of an application;
Returns:
true if and only if some application is registered for the given accessory guid.
Throws:
NullPointerException - if guid is null
Since:
BlackBerry API 7.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal