Android obtains wireless bluetooth Mac Information Code

Source: Internet
Author: User
Package Org. example. itester; import android. app. activity; import android. bluetooth. export thadapter; import android. content. context; import android. content. intent; import android.net. wiFi. wifiinfo; import android.net. wiFi. wifimanager; import android. OS. bundle; import android. widget. textview; public class wifibtcheck extends itester {Private Static final int request_enable_bt = 3; @ override public void oncreat E (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. wifibtcheck); mwifi = (wifimanager) getsystemservice (context. wifi_service); If (! Mwifi. iswifienabled () {mwifi. setwifienabled (true);} wifiinfo = mwifi. getconnectioninfo (); badapt = descrithadapter. getdefaadapter adapter (); If (badapt! = NULL) {If (! Badapt. isenabled () {intent enbt = new intent (effecthadapter. action_request_enable); startactivityforresult (enbt, request_enable_bt);} btmac = badapt. getaddress ();} else {btmac = "no Bluetooth device! ";} If (wifimac = wifiinfo. getmacaddress () = NULL) {wifimac = "no wifi device";} textview MAC = (textview) findviewbyid (R. id. macview); Mac. settextsize (38); Mac. settext ("wireless MAC:" + wifimac + "\ n Bluetooth Mac:" + btmac);} public void onactivityresult (INT requestcode, int resultcode, intent data) {Switch (requestcode) {Case request_enable_bt: // when the request to enable Bluetooth returns if (resultcode = activity. result_ OK) {// Bluetooth is now enabled, so set up a chat session} else {finish ();}}}}

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.