我正在開發(fā)一個(gè)需要 BT 連接的 Android 應(yīng)用程序。閱讀 Android 開發(fā)者頁面后,我們給出的方法isEnabled()不起作用。錯(cuò)誤是cannot resolve symbol isEnabled。導(dǎo)入的庫是android.bluetooth.BluetoothAdapter. 在清單文件中,按照Android頁面的說明,我還插入了藍(lán)牙、BT管理和精細(xì)位置的權(quán)限。代碼:public class MainActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);}BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();if (bluetoothAdapter == null) { Log.i("Fallo","Dispositivo sin bluetooth");}if (!bluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); }}
無法使用Android BT API方法
動(dòng)漫人物
2023-11-10 15:52:00