How to Use Android Bluetooth (Bluetooth details) and Android bluetoothI. Communication between bluetooth devices consists of four processes.
Configure a bluetooth device to search for devices that may match in the LAN to connect t
as central devices and cannot communicate with each other ).
Once the mobile phone is connected to the Activity Tracker, they can transmit GATT media data to each other. Based on the data they transmit, one party must assume the role of the server. For example, if an Activity Tracker wants to send sensor data to a mobile phone, the Activity Tracker must assume a server role. If the Activity Tracker wants to receive data from the mobile phone, the mobile phone must assume the role of the server.
central device roles and cannot communicate with each other).Once the phone and the activity tracker are connected, they can transfer the GATT media data to each other. Depending on the data they transmit, one party needs to assume the role of the server. For example, if the activity tracker wants to send sensor data to the phone, the activity tracker needs to serve as the server's role. If the activity tracker wants to receive data from the phone, the phone needs to serve as the server's role.
Oncharacteristicwrite gatt.wirteCharacteristic(mCurrentcharacteristic);
Connect bluetooth or disconnect bluetooth onconnectionstatechange
Readdescriptor corresponds to Ondescriptorread;
Writedescriptor corresponds to Ondescriptorwrite;gatt.writeDescriptor(descriptor);
Readremoterssi Correspondence Onreadremoterssi gatt.readRemoteRssi()
Executereliablewrite corresponds to onreliablewritecomplete
1. Modify the visibility of the local Bluetooth device
2. Scan the available Bluetooth devices around
Eg:
I. configuration file adroidmanifest. xml:
Ii. layout file: Main. xml:
3. mainactivity:
Import android. app. activity; import android. bluetooth. export thadapter;
(1) If you want to use the Bluetooth Android phone, you need to add Bluetooth access to the Androidmanifest file.Note: Permissions should be added to the Androidmanifest file (2) to determine if there is a Bluetooth device that can be used, if there is to determine whether the Blue
, ToastText, Toast.LENGTH_LONG). Show (); discoverable () ;}} 1.3 request user authorization so that the device can be found by other nearby devices: // request user authorization to make the device discoverable within 120 secondsPrivateVoidDiscoverable () {Intent discoverableIntent =NewIntent (effecthadapter.ACTION_REQUEST_DISCOVERABLE); StartActivity (discoverableIntent);} 2. Enable bluetooth device connection2.1For any
. BIND_APPWIDGET allows a program to tell the appWidget service to access the database of the small plug-in. This permission is only available to a very small number of applications.
Manage bound Devices
Android. permission. BIND_DEVICE_ADMIN: Request the receiver of the system administrator, which can only be used by the system.
Bind Input M
How to use Bluetooth with Android Bluetooth (details)I. Communication between bluetooth devices involves four steps
Set the bluetooth device to find data transmission between devices that may or match devices in the LAN
II. Specific programming implementation
1. Start the
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.I. What is Bluetooth?1.1 Buletooth is currently the most widely used wireless communication protocol1.2 Mainly for short-range equipment communication (10m)1.3 is commonly used to connect headphones, mouse and mobile communication devices.Two. Bluetooth-rela
Bluetooth is backwards compatible. Android phones must be system version 4.3 and above to support the BLE API.Bluetooth 2.0 Standard:
Bluetooth 2.0 Standard 2.0 is an improved version of 1.2, with a transfer rate of about1.8M/S~2.1M/S,
Start to support duplex mode------------for voice communication while also transferring files/high quality images
1. What is Bluetooth )?
1.1 buletooth is the most widely used wireless communication protocol.
1.2 mainly for short-range device communication (10 m)
1.3 is usually used to connect headphones, mouse, and mobile communication devices.
2. Bluetooth-related APIs
2.1 define thadapter:
Represents the local Bluetooth adapter
2.2 define thdevice
Represents a remot
A rough explanation of the communication between Android and Bluetooth Ble, android Bluetooth ble
First, briefly introduce ble features (Note: Bluetooth 4.0 is only supported by Android 4.3 or later)
1. BLE (
purpose exchange.The name of this profile is somewhat convoluted. It defines the transmission of data, including synchronization, file transfer. or push other data. Can understand the content-independent Transport layer protocol. Can be used to transfer custom data objects regardless of the application.13. Bluetooth Application SpecificationBr/edr profile (Android support)(1) A2DP (Advanced Audio Distribut
Use Bluetooth in the Android command line and Bluetooth in the android command line
Note: This part only applies to broadcom series bluetooth chips, such as RK903 and AP6xxx Series
Switch to the root user using the su command
1. confirm that the RFKILL driver has been loaded
somewhat confusing, it defines the transmission of data, including synchronization, file transfer, or pushing other data. The Transport layer protocol, which can be understood as content-independent, can be used by any application to transfer its own defined data objects.13. Bluetooth Application SpecificationBr/edr profile (Android support)(1) A2DP (Advanced Audio Distribution Profile)Advanced Audio, ster
information (allows applications to access information about networks)
Android. Permission. access_surface_flinger
Allow programs to use surfaceflinger underlying features (allows an application to use surfaceflinger's low level features)
Android. Permission. access_wifi_state
Allow programs to access Wi-Fi ne
[Android source code] BLE Bluetooth communication javasth_4.3, android Bluetooth ble DevelopmentThis Demo is compatible with Bluetooth communication between BLE Android terminal devices.Main functions include:1. Enable and disable
work (this was stipulated in the agreement, otherwise it would call can Not answer with headset or carkit) headset or carkit query link time interval is different (the main link establishment ne Gotiation by the parties in the decision), so standby current performance of different products not the same, as shown in Figure 1 are the phone Kewei connection after OTA (Air Packet analyzer), OTA showed, the POLL and NULL interaction of S Ystem is very frequent (Kewei as the main initiate POLL), whic
location providers for testing)
Android. permission. ACCESS_NETWORK_STATEAllow a program to access GSM network information (Allows applications to access information about networks)
Android. permission. ACCESS_SURFACE_FLINGERAllow programs to use SurfaceFlinger underlying features (Allows an application to use Surface
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.