wpjr2’s Weblog

Artigos e tutoriais úteis

Detectando Bluetooth em Dispositivos JavaME

Publicado por wpjr2 em Junho 17, 2008

Bluetooth

Como é possivel detectarmos se a JSR 82 (Bluetooth API) está presente do dispositivo? Existem várias maneiras de verificar isto. Porém, a mais recomendada é a apresentada abaixo, já que esta verifica diretamente a existência de uma classe dentro da API do aparelho.

import javax.bluetooth.*;

String BluetoothVersion = null;
boolean isBluetoothHere = true;

try {
Class.forName( “javax.bluetooth.LocalDevice” ); // does the class exist?

BluetoothVersion = javax.bluetooth.LocalDevice.getProperty( “bluetooth.api.version” );

} catch( ClassNotFoundException cnf ) { // class does not exist -> no Bluetooth
isBluetoothHere = false;
}

Deixe um comentário

XHTML: Você pode usar estas tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>