One, bluetoothadapter--Bluetooth adapter (native)
There are many methods in Bluetoothadapter, commonly used are the following:
(1) canceldiscovery () by literal means, is to cancel the discovery, that is, when we are searching the device, call this method will not continue to search
(2) Disable () Turn off Bluetooth
(3) Enable () Turn on Bluetooth, this method to turn on Bluetooth will not pop up the prompt,
More time we need to ask if the user is open, the following two lines of code is also open Bluetooth, but will prompt the user:
Intent enableintent = new Intent (bluetoothadapter.action_request_enable);
Startactivityforresult (Enableintent, REQUEST_ENABLE_BT);//can also be written startactivity (enableintent);
(4) getaddress () get local Bluetooth address
(5) Getdefaultadapter () Gets the default Bluetoothadapter, in fact, there is only one way to get Bluetoothadapter
(6) GetName () get the local Bluetooth name
(7) Getremotedevice (String address) to obtain a remote Bluetooth device based on the Bluetooth location
(8) GetState () Gets the current status of the local Bluetooth adapter (more needed when it feels possible to debug)
(9) Isdiscovering () to determine whether the device is currently being looked up, is true
() isenabled () to determine if Bluetooth is turned on, turned on returns True, otherwise, returns false
(one) Listenusingrfcommwithservicerecord (String name,uuid uuid) by name, UUID creates and returns Bluetoothserversocket, This is the first step in creating a Bluetoothsocket server side
StartDiscovery () Start search, this is the first step in searching
Second, bluetoothdevice--Bluetooth device (remote)
Createrfcommsockettoservicerecord (UUIDUUID) creates and returns a bluetoothsocket based on the UUID
This approach is also the purpose of our acquisition of Bluetoothdevice-creating Bluetoothsocket
Other methods of this class, such as GetAddress (), GetName (), with Bluetoothadapter
Three, bluetoothsocket--Bluetooth socket interface
Iv. bluetoothserversocket--represents an open server socket that listens for incoming connection requests
Five, Bluetooth package also has 4 classes, Bluetoothclass, Bluetoothclass.device, BluetoothClass.Device.Major, Bluetoothclass.service
Android Bluetooth Development (ii): Introduction to related APIs