how to turn Bluetooth on/off with J2ME?

2019-06-28 00:09发布

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.

3条回答
Root(大扎)
2楼-- · 2019-06-28 00:31

No way. We cannot be able to automatically turn on/off bluetooth in java & j2me. Better you refer to the documentation of JSR 82

查看更多
冷血范
3楼-- · 2019-06-28 00:35

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.

查看更多
The star\"
4楼-- · 2019-06-28 00:37

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.

查看更多
登录 后发表回答