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.
- Go to Oracle's Website and download the J2ME libraries/packages from Oracle.
- 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();
精彩评论