org.simalliance.openmobileapi
Class SEService

java.lang.Object
  extended by org.simalliance.openmobileapi.SEService

public class SEService
extends java.lang.Object

The SEService realises the communication to available Secure Elements on the device. This is the entry point of this API. It is used to connect to the infrastructure and get access to a list of Secure Element Readers.

See Also:
SIMalliance Open Mobile API v2.02

Nested Class Summary
static interface SEService.CallBack
          Interface to receive call-backs when the service is connected.
 
Constructor Summary
SEService(android.content.Context context, SEService.CallBack listener)
          Establishes a new connection that can be used to connect to all the Secure Elements available in the system.
 
Method Summary
static android.content.Intent createExplicitFromImplicitIntent(android.content.Context context, android.content.Intent implicitIntent)
          Android L (lollipop, API 21) introduced a new problem when trying to invoke implicit intent, "java.lang.IllegalArgumentException: Service Intent must be explicit" If you are using an implicit intent, and know only 1 target would answer this intent, This method will help you turn the implicit intent into the explicit form.
protected  java.lang.String[] getPcscReadersName()
           
 Reader[] getReaders()
          Returns the list of available Secure Element readers.
 boolean isConnected()
          Tells whether or not the service is connected.
protected  void setNfcTag(android.nfc.Tag tag)
           
protected  void setPcscReaderName(java.lang.String name)
           
 void shutdown()
          Releases all Secure Elements resources allocated by this SEService.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SEService

public SEService(android.content.Context context,
                 SEService.CallBack listener)
Establishes a new connection that can be used to connect to all the Secure Elements available in the system. The connection process can be quite long, so it happens in an asynchronous way. It is usable only if the specified listener is called or if isConnected() returns true.
The call-back object passed as a parameter will have its serviceConnected() method called when the connection actually happen.

Parameters:
context - the context of the calling application. Cannot be null.
listener - a SEService.CallBack object. Can be null.
Method Detail

createExplicitFromImplicitIntent

public static android.content.Intent createExplicitFromImplicitIntent(android.content.Context context,
                                                                      android.content.Intent implicitIntent)
Android L (lollipop, API 21) introduced a new problem when trying to invoke implicit intent, "java.lang.IllegalArgumentException: Service Intent must be explicit" If you are using an implicit intent, and know only 1 target would answer this intent, This method will help you turn the implicit intent into the explicit form. Inspired from SO answer: http://stackoverflow.com/a/26318757/1446466

Parameters:
context -
implicitIntent - - The original implicit intent
Returns:
Explicit Intent created from the implicit original intent

isConnected

public boolean isConnected()
Tells whether or not the service is connected.

Returns:
true if the service is connected.

getPcscReadersName

protected java.lang.String[] getPcscReadersName()

setPcscReaderName

protected void setPcscReaderName(java.lang.String name)

setNfcTag

protected void setNfcTag(android.nfc.Tag tag)

getReaders

public Reader[] getReaders()
Returns the list of available Secure Element readers. More precisely it returns the list of readers that the calling application has the permission to connect to.

Returns:
The readers list, as an array of Readers. If there are no readers the returned array is of length 0.

shutdown

public void shutdown()
Releases all Secure Elements resources allocated by this SEService. It is recommended to call this method in the termination method of the calling application (or part of this application) which is bound to this SEService. The SEService becomes invalid after calling shutdown().