|
Copyright 2008 Motorola Inc. and Nokia Corporation. All Rights Reserved. Specification License |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.broadcast.platform.PlatformProviderSelector
public class PlatformProviderSelector
PlatformProviderSelector
provides the methods for discovering
the underlying broadcast platform providers and selecting one of them
for use. A
selection
establishes the source, communication protocol and the physical
transmission medium of the broadcast services.
PlatformProvider
By default, a platform provider is selected in the beginning of the application lifecycle.
In very rare cases, for example, if the broadcast receiver has never
been used before after the purchase, a PlatformProvider
might not selected.
In general case, the implementation remembers the previous
PlatformProvider
selection (independently of the way the selection was
made - by a Java application or by a native application). However, it is a good idea
to use getCurrentProvider()
method to check if there is a selected provider in the beginning
of the application.
When selecting a PlatformProvider
, there are two ways to identify the PlatformProvider
before the actual selection. The first way is to first use discover()
method to search for available providers,
then pick one from getAvailableProviders()
and select that by select(PlatformProvider)
method; the alternative way, that can be used only if the application knows the frequency
and the id of the provider beforehand, is to create a PlatformProvider
instance
with createPlatformProvider(int, long, java.lang.String)
method and then select that by select(PlatformProvider)
method.
The device might have a default PlatformProvider that can be queried by using
the getDefaultProvider()
method.
ServiceContext
,
ServiceGuide
Method Summary | |
---|---|
static void |
abort()
Stops the current search for the available platform providers. |
static void |
addListener(PlatformProviderSelectorListener ppl)
Registers a listener. |
static PlatformProvider |
createPlatformProvider(int frequency,
long id,
java.lang.String name)
Instantiates a PlatformProvider directly based
on the broadcast frequency and the ID number. |
static void |
discover()
Starts a search for the available platform providers. |
static PlatformProvider[] |
getAvailableProviders()
Returns available PlatformProviders (that have been found by discovering). |
static PlatformProvider |
getCurrentProvider()
Queries the current platform provider. |
static java.util.Date |
getCurrentProviderDate()
Returns the current time of the selected broadcast network provider. |
static PlatformProvider |
getDefaultProvider()
Returns the default PlatformProvider. |
static void |
removeListener(PlatformProviderSelectorListener ppl)
Unregisters a listener. |
static void |
select(PlatformProvider pp)
Selects a platform provider. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void abort()
When discovery is aborted PlatformProviderSelectorListener.update()
is called before this method returns to notify the reached progress, number of found service providers and that the discovery
is not continuing.
public static void addListener(PlatformProviderSelectorListener ppl)
ppl
- The listener to add.
If null
is given or if the given listener
is already added, the method is silently ignored.public static PlatformProvider createPlatformProvider(int frequency, long id, java.lang.String name) throws UnsupportedOperationException
PlatformProvider
directly based
on the broadcast frequency and the ID number.
This method can be used in place of discover()
and getAvailableProviders()
to identify a provider
manually, if the application has direct access to the
available frequency and ID. This creation method does not do any kind
of validation or selection of the PlatformProvider; it just instantiates
a PlatformProvider instance that can be used with select method, which
does the validation and selection if the frequency and the ID information
matches with an actual provider in broadcast.
Parameters are validated only if manual identification of PlatformProvider
s is supported.
frequency
- The broadcast frequency of the provider in
kilohertz.id
- The ID of the provider.name
- The name of the provider. The name is not used as identifier when selecting
this provider, but it is only stored for toString method of the PlatformProvider.
When this provider is selected, the name will be replaced by the name transmitted in broadcast.
PlatformProvider
given the information;
UnsupportedOperationException
- if the implementation does not
support manually identifying PlatformProviders
.
java.lang.IllegalArgumentException
- if the given frequency is zero or negative number
java.lang.NullPointerException
- if name is null.public static void discover()
This method updates the list of available service providers. Result is the best estimation of the available service providers after the discovery has been completed. For instance, the list may be unchanged when there is no radio coverage.
The mechanism to discover the available platform providers is implementation dependent. For example, some implementations may perform a frequency scan and others may be based on a direct reception of the frequency table via a mobile link. Because of this, the time it takes for the discovery process may vary greatly across different implementations.
This method is asynchronous and applications should use
a PlatformProviderSelectorListener
to monitor the
progress. The listener is notified at least once during each discovery: when discovery is completed or
when discovery is aborted.
Discovery is typically a mutually exclusive operation while a ServiceContext is in PRESENTING or in PRESENTATION_PENDING state. Therefore, you might get RESOURCE_UNAVAILABLE event to ServiceContextListener when using this method. However, selected platform remains selected after the discover finishes if the platform is still available.
Calling discover
again while another discover
is in progress is a no-op.
PlatformProviderSelectorListener
public static PlatformProvider[] getAvailableProviders()
public static PlatformProvider getCurrentProvider()
null
will be returned.
The implementation might remember the previous selection
from a previous run of a Java or a native application.
null
if no platform provider has been selectedpublic static java.util.Date getCurrentProviderDate()
null
.
java.lang.IllegalStateException
- if there is no selected broadcast
network provider.public static PlatformProvider getDefaultProvider() throws BroadcastServiceException
null
.
BroadcastServiceException
- if the implementation does not have
a default platform provider.public static void removeListener(PlatformProviderSelectorListener ppl)
ppl
- The listener to unregister.
If null
is given or if the given listener is already removed,
the method is silently ignored.public static void select(PlatformProvider pp)
If there is a platform provider previously selected, it will be de-selected.
And any ServiceGuides
that are associated with the previous
platform provider will be
invalidated. After each call to select
, applications should
obtain a new set of ServiceGuides
.
See ServiceGuide.getDefaultServiceGuide()
and
ServiceGuide.getAllServiceGuides()
.
This method may take some time to complete.
java.lang.NullPointerException
- if the argument is null
.
java.lang.IllegalArgumentException
- the given PlatformProvider
is not available
|
Copyright 2008 Motorola Inc. and Nokia Corporation. All Rights Reserved. Specification License |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |