Getting started with Android Bluetooth Development

Source: Internet
Author: User

This article only provides a relatively simple example of Bluetooth development. If you like android, you can just give it a try and think about it, small cainiao recommended parents read understand this blog after the column, then have a look at the little cainiao reprint good blog, address http://blog.csdn.net/woshishuoshuoa/article/details/9709371 ~~~ We sincerely welcome your valuable suggestions ~~~

1. Source Code:

Package com.example.com _ diecolor_demo13; import Java. util. list; import android.net. wiFi. wificonfiguration; import android.net. wiFi. wifiinfo; import android.net. wiFi. wifimanager; import android.net. wiFi. wifimanager. wifilock; import android. OS. bundle; import android. widget. textview; import android. widget. toast; import android. app. activity; public class mainactivity extends activity {textview; wifiman Ager wifimanager; wificonfiguration; wifiinfo; wifilock; @ overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. activity_main); textview = (textview) findviewbyid (R. id. TV _main); wifimanager = (wifimanager) getsystemservice (wifi_service); // obtain the wifimanager object toast. maketext (this, "WiFi status:" + wifimanager. getwifist Ate (), 3000). Show (); If (! Wifimanager. iswifienabled () {// wifimanager. iswifienabled () determines whether WiFi is enabled // enable wifiwifimanager. setwifienabled (true); toast. maketext (this, "Current WiFi status:" + wifimanager. getwifistate (), 3000 ). show () ;}list <wificonfiguration> List = wifimanager. getconfigurednetworks (); // The configured list wifiinfo = wifimanager. getconnectioninfo (); // obtain the network connection information wifilock = wifimanager. createwifilock (1, "laoc"); // lock stringbuffer buffer = new stringbuffer (); For (wificonfiguration: List) {string tempstring = ""; tempstring + = "SSID: "+ wificonfiguration. SSID + "\ n" + "network ID" + inttoip (wificonfiguration. networkid) + "presponkey" + wificonfiguration. presharedkey + "status" + wificonfiguration. status + "Speed:" + wifiinfo. getlinkspeed (); buffer. append (tempstring);} textview. settext (buffer);}/** convert an int-type IP address to a 4-segment IP address **/private string inttoip (int ip) {return (IP & 0xff) + ". "+ (ip> 8) & 0xff) + ". "+ (ip> 16) & 0xff) + (ip> 24) & 0xff );}}

In androidmanifest. xml

2. Running result:

3. Conclusion: This column is just a simple introduction to some simple things about Bluetooth development... Not complete, To be continued...

 

Related Article

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.