カテゴリー
SugiBlog Webデザイナー・プログラマーのためのお役立ちTips

Bluetoothを扱う Android

AndroidでBluetoothを使ってみます。

Bluetoothアダプタークラスをインポート

import android.bluetooth.BluetoothAdapter;

アダプターとリクエストコードの定義

BluetoothAdapter mBluetoothAdapter = null;
final int REQUEST_ENABLE_BT = 1; //任意のコード

アクティビティのonCreateでアダプターをセットします。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

	mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}

続きを読む…»

7,138 views