How to turn on / off Bluetooth using J2ME?

I want to write a program in J2ME to automatically turn on / off Bluetooth at a specific time without user permission.

I searched for a while, but I could not find an answer.

+4
source share
3 answers

Some phones automatically turn bluetooth ON when the MIDlet starts using the Java Java Java API.

Other phones will not.

AFAIK, there is no Java ME API to enable / disable bluetooth.

I have yet to find a mobile phone that automatically switches bluetooth OFF after a while of inactivity.

In any case, if you do this (I'm sure this is possible in Symbian OS C ++, for example), it will be platform dependent.

+3
source

There is definitely to not programmatically enable or disable Bluetooth in Java ME. However, it may be useful to switch between detection modes:

LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC); 

to detect and

 LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.NOT_DISCOVERABLE); 

to hide from other devices. It does not save battery, but it does things that are a little safer, I think.

+1
source

In no case. We cannot automatically turn on / off bluetooth in java and j2me. You better refer to the JSR 82 documentation

0
source

Source: https://habr.com/ru/post/1303949/


All Articles