Android Bluetooth Communication Programming memo

Source: Internet
Author: User

1. After launching the app:

Determine if Bluetooth is turned on (all functions must be used in case of tooth opening)

Turned on: Bluetooth Communication Service in startup code

Not open: Publish turns on Bluetooth intent (System) and returns to the entry operation based on activity

Turn on success, start the Bluetooth communication Service in code

User points back or fails to exit the app

2. Bluetooth Device list:

2.1 Show already paired list:

Registering a Bluetooth Device Discovery broadcast

Add the discovered devices to the list in the broadcast
2.2 When the user points to scan, the Bluetooth discovery is initiated and a broadcast event is received when the device is discovered.

2.3 When a user points an entry, the Mac that changes the entry is returned to the main activity (Startactivityforresult activity is called)

3. Enable the device to discover

    Private void ensurediscoverable () {        "ensure discoverable");         if (Mbluetoothadapter.getscanmode ()! =            bluetoothadapter.scan_mode_connectable_discoverable)            { New Intent (bluetoothadapter.action_request_discoverable);              - );            StartActivity (discoverableintent);        }    }
View Code

Android Bluetooth Communication Programming memo

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.