Skip to content

Instantly share code, notes, and snippets.

@ueno-yuhei
Last active August 29, 2015 14:01
Show Gist options
  • Save ueno-yuhei/167ccfb28e6ca22c4944 to your computer and use it in GitHub Desktop.
Save ueno-yuhei/167ccfb28e6ca22c4944 to your computer and use it in GitHub Desktop.
Bluetooth ON OFF 切り替え
public static class BluetoothChanger{
/**
* Bluetooth ON OFF
*/
public static void setState(Context context,Boolean buletoothState){
BluetoothAdapter mBtAdapter = BluetoothAdapter.getDefaultAdapter();
if( !(mBtAdapter == null) ){
if (buletoothState == true){
mBtAdapter.enable();
} else {
mBtAdapter.disable();
}
}else{
Toast.makeText(context,"お使いの端末はBluetoothをサポートしておりません。", 1000).show();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment