AndroidManifest 권한 설정
<protected-broadcast android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<uses-permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
<activity
android:exported="true"
도 하고
BT_On()
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
IAllowYouToFindMeDuring300s()
Intent discoverableIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
IntentOfBTScanMenu()
startActivity(new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS));
Android 플랫폼이 추상화를 참 잘해놔서
C++과는 달리 JAVA+Android Studio는 필요한 애들을 자동으로 다운로드하고 실행하게 잘해놔서 API 호출 코드 몇줄이면, 정말 편하게 만든다.
최근댓글