|
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | ||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
Objectcom.docomostar.device.Bluetooth
public class Bluetooth
端末の Bluetooth 機能を表すクラスを定義します。
このクラスでは、端末の Bluetooth 機能を呼び出して、 外部機器の検索、機器選択、機器登録、各種設定などを行います。 外部機器が選択されると、その外部機器に対応したRemoteDeviceクラスのオブジェクトを取得します。
[Star-1.5 以降]
searchDevice()
により周辺の外部機器を検索し、
見つかった外部機器の情報として DeviceDiscoveryResult オブジェクトを取得することができます。
この DeviceDiscoveryResult オブジェクトを
startPairing(DeviceDiscoveryResult)
の引数に指定することで機器登録ができます。
また、getDiscoveredRemoteDeviceList()
により現在端末に登録されている外部機器のリストを取得することができます。
RemoteDevice
,
BTStateListener
,
BTConnection
,
SPPConnection
フィールドの概要 | |
---|---|
static int |
HDP
ヘルスデバイスプロファイルを表します(=1)。 |
static int |
OOB_CHANNEL_FELICA
OOB の通信路として FeliCa の DataExchange 機能を利用することを表します(=0)。 |
static int |
SPP
シリアルポートプロファイルを表します(=0)。 |
static int |
TYPE_INITIATOR
外部機器への接続を要求することを表します(=0)。 |
static int |
TYPE_RESPONDER
外部機器からの接続要求を待ち受けることを表します(=1)。 |
メソッドの概要 | |
---|---|
int |
getDiscoveredDevice()
ネイティブの登録機器リストに保持されている外部機器の数を取得します。 |
RemoteDevice |
getDiscoveredRemoteDevice(DeviceDiscoveryResult targetDevice)
指定した DeviceDiscoveryResult オブジェクトに対応した、 ネイティブの登録機器リストに保持されている外部機器を取得します。 |
RemoteDevice[] |
getDiscoveredRemoteDeviceList()
ネイティブの登録機器リストに保持されている外部機器のリストを取得します。 |
int |
getInquiryTimeout()
Inquiryの実行時間を取得します。 |
static Bluetooth |
getInstance()
端末の Bluetooth 機能を表すインスタンスを取得します。 |
int |
getMaxConnection(int type)
引数に指定したプロファイルに対して、 この端末の Bluetooth 未接続状態における同時に接続可能な数を返します。 |
boolean |
isConnectable(int type)
引数に指定したプロファイルで外部機器とStar アプリが接続可能であるか否かを取得します。 |
boolean |
isDetachmentMode()
機器登録処理後に接続(ACLリンク)を切断するかどうかを返します。 |
RemoteDevice |
scan()
外部機器からの接続要求を待ち、 ユーザが外部機器との接続を選択した場合にRemoteDeviceオブジェクトが生成されます。 |
RemoteDevice |
searchAndSelectDevice()
外部機器探索を行い、ユーザによる外部機器の選択を行います。 |
DeviceDiscoveryResult[] |
searchDevice()
外部機器検索を行います。 |
RemoteDevice |
selectDevice()
ユーザによる外部機器の選択を行います。 |
void |
setDetachmentMode(boolean flag)
機器登録処理後に接続(ACLリンク)を切断するかどうかを設定します。 |
void |
setInquiryTimeout(int time)
Inquiryの実行時間を設定します。 |
RemoteDevice |
startPairing(DeviceDiscoveryResult targetDevice)
外部機器の検索結果を指定し、外部機器との接続を行います。 |
RemoteDevice |
startPairingByOOB(int channel,
int type,
byte[] handoverId)
Bluetooth 帯域外(Out Of Band)の通信路を用いて外部機器との接続を行います。 |
void |
turnOff()
Bluetooth電源をオフにします。 |
クラス Object から継承されたメソッド |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
フィールドの詳細 |
---|
public static final int SPP
RemoteDevice.isAvailable(int)
,
RemoteDevice.connect(int)
,
RemoteDevice.accept(int)
,
isConnectable(int)
,
定数フィールド値public static final int HDP
RemoteDevice.isAvailable(int)
,
RemoteDevice.connect(int)
,
RemoteDevice.accept(int)
,
isConnectable(int)
,
定数フィールド値public static final int OOB_CHANNEL_FELICA
startPairingByOOB(int, int, byte[])
,
定数フィールド値public static final int TYPE_INITIATOR
startPairingByOOB(int, int, byte[])
,
定数フィールド値public static final int TYPE_RESPONDER
startPairingByOOB(int, int, byte[])
,
定数フィールド値メソッドの詳細 |
---|
public static Bluetooth getInstance()
パーミッションとしてBluetooth APIの利用が許可されているトラステッドStar アプリのみ、 このメソッドを呼び出すことができます。
端末によっては、Bluetooth 機能をサポートしていない場合があります。 その場合には、例外 UnsupportedOperationException が発生します。
UnsupportedOperationException
-
SecurityException
-
public RemoteDevice scan() throws InterruptedOperationException
メソッドを呼び出すとStar アプリはサスペンドし、 ネイティブでInquiry ScanとPage Scanが同時に実行されます。 外部機器が未登録である場合には、 ペアリング処理や登録処理がネイティブ側で行われます。 処理終了後、Star アプリはレジュームします。
SecurityException
-
DeviceException
- DeviceException
- BluetoothException
- BluetoothException
- BluetoothException
- BluetoothException
- イベントリスナ
により接続要求を待っている場合に発生します。
BluetoothException
- InterruptedOperationException
-
public RemoteDevice selectDevice() throws InterruptedOperationException
このメソッドを呼び出すとStar アプリはサスペンドし、 ネイティブに処理が切り替わります。 機器登録済みの外部機器の一覧が表示され、 ユーザが一覧から機器を選択することでRemoteDeviceオブジェクトが生成されます。 なお、一覧に選択できる機器がなかった場合には、ユーザのキャンセルでStar アプリに戻ります。
既に生成された RemoteDevice オブジェクトを dispose しない限り、 複数回このメソッドの呼び出しにより同一機器が選択されても、 同一の有効な RemoteDevice オブジェクトへの参照が返されます。 RemoteDevice オブジェクトを dispose してから、 このメソッドの呼び出しにより同一機器が選択されると、 新しく有効な RemoteDevice オブジェクトが生成されて返されます。
SecurityException
-
DeviceException
- DeviceException
- BluetoothException
- InterruptedOperationException
-
public RemoteDevice searchAndSelectDevice() throws InterruptedOperationException
このメソッドを呼び出すとStar アプリはサスペンドし、 ネイティブに処理が切り替わります。 ネイティブで DeviceDiscovery処理が実行され周辺の外部機器情報を取得します。 その後、接続可能な外部機器の一覧が表示され、 ユーザが一覧から機器を選択することでRemoteDeviceオブジェクトが生成されます。
既に生成された RemoteDevice オブジェクトを dispose しない限り、 複数回このメソッドの呼び出しにより同一機器が選択されても、 同一の有効な RemoteDevice オブジェクトへの参照が返されます。 RemoteDevice オブジェクトを dispose してから、 こそ繝ォ縺励◆蝣エ蜷医↓縺ッ null 繧定ソ斐@縺セ縺吶