BluetoothAdapter | Android Developers
getDefaultAdapterでデフォルトのアダプタインスタンスを取得。
実機の場合は取得できたが、エミュレータの場合はどうなるか。
strings.xmlで、
Button1。
activity_main.xmlで、
Button。
MainActivity.javaで、
BluetoothAdapter.getDefaultAdapterでインスタンス取得できるかnullかを試す。
AndroidManifest.xmlで、
android.permission.BLUETOOTHを書いている。
![右下のSettingsを押す](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20201212/20201212202909.png)
右下のSettingsを押す。
![BluetoothはOFF](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20201212/20201212202947.png)
BluetoothはOFF。
![起動時](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20201212/20201212203030.png)
起動時。
Button1を押すと、
![not supportedなのでnullが返ってきてる](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20201212/20201212203120.png)
not supportedなのでnullが返ってきてる。
![BluetoothをONにする](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20201212/20201212203206.png)
BluetoothをONにする。
![ONOFF関係なくエミュレータはnot supportedみたい](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20201212/20201212203243.png)
ONOFF関係なくエミュレータはnot supportedみたい。