how to turn Bluetooth on/off with J2ME?
I want to write a program in J2ME to turn the Bluetooth 开发者_如何转开发on/off automaticly in a certain time without the user permission.
I'v been looking for a while but I couldn't find an answer.
Some phones will automatically switch bluetooth ON when a MIDlet starts using the Java ME Bluetooth API.
Other phones will not.
AFAIK, there is no Java ME API to switch bluetooth ON/OFF.
I have yet to find a mobile phone that automatically switches bluetooth OFF after some time of inactivity.
Any way you find to do this (I'm sure it's doable in Symbian OS C++, for example) will be platform-dependant.
There is definitely no way to programmatically switch your Bluetooth on and off in Java ME. However what may be useful is to switch between discoverable modes:
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
to be discoverable, and
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.NOT_DISCOVERABLE);
to hide from other devices. It doesn't save battery, but it does make things that little bit more secure I guess.
No way. We cannot be able to automatically turn on/off bluetooth in java & j2me. Better you refer to the documentation of JSR 82
精彩评论