开发者

Can I enable bluetooth on a mobile device with java?

开发者 https://www.devze.com 2023-01-09 02:06 出处:网络
sorry for my bad english, can someone开发者_JAVA百科 tha has worked with java on a mobile device (cell phone) tell me if its possible to enable the bluetooth connection of the device from a java appli

sorry for my bad english, can someone开发者_JAVA百科 tha has worked with java on a mobile device (cell phone) tell me if its possible to enable the bluetooth connection of the device from a java application?

thanks


Yes, it's absolutely possible with J2ME (Java 2 Micro Edition). I did this 3 years back so I have little knowledge.

  1. Go to Oracle's Website and download the J2ME libraries/packages from Oracle.
  2. Follow example here and here for tutorial how to connect to bluetooth device.


BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
//for enable blutooth(Turn on)
Intent eintent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(eintent, 1);
//for disable(Turn of)
bluetoothAdapter.disable();
0

精彩评论

暂无评论...
验证码 换一张
取 消