XtGem Forum catalog
↓↓xuống cuối trang↓↓
Chào mừng bạn đến với wap DinhLoi.XtGem.Com | Chúc bạn có 1 năm mới vui vẻ tốt lành hạnh phúc! Hãy giới thiệu website này cho bạn bè nhé!img
DinhLoi.XtGem.Com =>> CaFe9x.Gq
Bạn đến từ quốc gia:



Hôm nay ngày
19.04.24/03:56
img- Hi. Xin chào! Mozilla/5.0
logo
.
HOMECHÁTTruyệnFORUM
Trang chủ>Thủ thuật>Xử lí Java>
Bluetooth in j2me
15.07.2014/12:48
javatips
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.bluetooth.*; publicclassBluetoothMidletextendsMIDletimplementsCommandListener {private Display display; private Command exit; LocalDevice local; Alert a; public BluetoothMidlet () { display = Display.getDisplay ( this ) ; exit = new Command ( "Exit" ,Command.EXIT, 0 ) ; a = new Alert ( "Local Device" ) ; a.addCommand ( exit ) ; a.setCommandListener ( this ) ; } publicvoid startApp () { try { // Retrieve the local Bluetooth device objectlocal = LocalDevice.getLocalDevice () ; // Retrieve the Bluetooth addressof the local deviceString address = local.getBluetoothAddress () ; // Retrieve the name of the local Bluetooth deviceString name = local.getFriendlyName () ; System.out.println ( address + name ) ; a.setString ( "Address is" +address+ " Name is " +name ) ; display.setCurrent ( a ) ; } catch ( Exception e ) { e.printStackTrace () ; } } publicvoid pauseApp () {} publicvoid destroyApp ( boolean unconditional ) {} publicvoid commandAction ( Command c,Displayable d ) { if ( c == exit ) { notifyDestroyed () ; destroyApp ( true ) ; } } }
Mã này để dò thiết bị Bluetooth và hiển thị ra tên thiết bị Bluetooth Hay còn để hiển thị địa chỉ bluetút thiết bị đang dùng. Chúc các bạn lập trình j2me thành công
Tag:
Bạn đến từ:
Share: img img img img img

Thanks To:XtGem
Liên kết:U-ON