當前位置:編程學習大全網 - 網站源碼 - android開發藍牙 單面機設備uuid是16位,那android這邊怎麽處理

android開發藍牙 單面機設備uuid是16位,那android這邊怎麽處理

Android藍牙編程的基本步驟:1.獲取藍牙適配器BluetoothAdapterblueadapter=BluetoothAdapter.getDefaultAdapter();如果BluetoothAdapter為null,說明android手機沒有藍牙模塊。判斷藍牙模塊是否開啟,blueadapter.isEnabled()true表示已經開啟,false表示藍牙並沒啟用。2.啟動配置藍牙可見模式,即進入可配對模式Intentin=newIntent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);in.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,200);startActivity(in);,200就表示200秒。3.獲取藍牙適配器中已經配對的設備Setdevice=blueadapter.getBondedDevices();4.還需要在androidManifest.xml中聲明藍牙的權限接下來就是根據自己的需求對BluetoothAdapter的操作了。

  • 上一篇:如何取消綁定易信上的雲筆記賬號?
  • 下一篇:如何在Visual Studio Code 中運行 Python
  • copyright 2024編程學習大全網