com.thingmagic
Class AndroidBluetoothReflection

java.lang.Object
  extended by com.thingmagic.AndroidBluetoothReflection

public class AndroidBluetoothReflection
extends java.lang.Object

Provides access to Android Bluetooth classes via Java reflection.


Constructor Summary
AndroidBluetoothReflection()
           
 
Method Summary
static boolean checkBluetoothAddress(java.lang.Object bluetoothAdapter, java.lang.String address)
          Invokes the method android.bluetooth.BluetoothAdapter#checkBluetoothAddress.
static void closeBluetoothSocket(java.lang.Object bluetoothSocket)
          Invokes the method android.bluetooth.BluetoothSocket#close.
static void connectToBluetoothSocket(java.lang.Object bluetoothSocket)
          Invokes the method android.bluetooth.BluetoothSocket#connect.
static java.lang.Object createBluetoothSocket(java.lang.Object bluetoothDevice)
          Invokes the method android.bluetooth.BluetoothDevice#createRfcommSocketToServiceRecord.
static java.lang.Object getBluetoothAdapter()
          Invokes the method android.bluetooth.BluetoothAdapter#getDefaultAdapter.
static java.io.InputStream getInputStream(java.lang.Object bluetoothSocket)
          Invokes the method android.bluetooth.BluetoothSocket#getInputStream.
static java.io.OutputStream getOutputStream(java.lang.Object bluetoothSocket)
          Invokes the method android.bluetooth.BluetoothSocket#getOutputStream.
static java.lang.Object getRemoteDevice(java.lang.Object bluetoothAdapter, java.lang.String address)
          Invokes the method android.bluetooth.BluetoothAdapter#getRemoteDevice.
static boolean isBluetoothEnabled(java.lang.Object bluetoothAdapter)
          Invokes the method android.bluetooth.BluetoothAdapter#isEnabled.
static boolean isBonded(java.lang.Object bluetoothDevice)
          Invokes the method android.bluetooth.BluetoothDevice#getBondState.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidBluetoothReflection

public AndroidBluetoothReflection()
Method Detail

getBluetoothAdapter

public static java.lang.Object getBluetoothAdapter()
Invokes the method android.bluetooth.BluetoothAdapter#getDefaultAdapter.

Returns:
a android.bluetooth.BluetoothAdapter object, or null if Bluetooth is not available

isBluetoothEnabled

public static boolean isBluetoothEnabled(java.lang.Object bluetoothAdapter)
Invokes the method android.bluetooth.BluetoothAdapter#isEnabled.

Parameters:
bluetoothAdapter - a android.bluetooth.BluetoothAdapter object
Returns:
true if Bluetooth is enabled, false otherwise

checkBluetoothAddress

public static boolean checkBluetoothAddress(java.lang.Object bluetoothAdapter,
                                            java.lang.String address)
Invokes the method android.bluetooth.BluetoothAdapter#checkBluetoothAddress.

Parameters:
bluetoothAdapter - a android.bluetooth.BluetoothAdapter object
address - a string that might be a bluetooth MAC address
Returns:
true if the address is valid, false otherwise

isBonded

public static boolean isBonded(java.lang.Object bluetoothDevice)
Invokes the method android.bluetooth.BluetoothDevice#getBondState.

Parameters:
bluetoothDevice - a android.bluetooth.BluetoothDevice object
Returns:
the bond state of the given android.bluetooth.BluetoothDevice

getRemoteDevice

public static java.lang.Object getRemoteDevice(java.lang.Object bluetoothAdapter,
                                               java.lang.String address)
                                        throws java.lang.IllegalArgumentException
Invokes the method android.bluetooth.BluetoothAdapter#getRemoteDevice.

Parameters:
bluetoothAdapter - a android.bluetooth.BluetoothAdapter object
address - the bluetooth MAC address of the device
Returns:
a android.bluetooth.BluetoothDevice object
Throws:
java.lang.IllegalArgumentException

createBluetoothSocket

public static java.lang.Object createBluetoothSocket(java.lang.Object bluetoothDevice)
                                              throws java.io.IOException
Invokes the method android.bluetooth.BluetoothDevice#createRfcommSocketToServiceRecord.

Parameters:
bluetoothDevice - a android.bluetooth.BluetoothDevice object
uuid - the service record uuid
Returns:
a android.bluetooth.BluetoothSocket object
Throws:
java.io.IOException

connectToBluetoothSocket

public static void connectToBluetoothSocket(java.lang.Object bluetoothSocket)
                                     throws java.io.IOException
Invokes the method android.bluetooth.BluetoothSocket#connect.

Parameters:
bluetoothSocket - a android.bluetooth.BluetoothSocket object
Throws:
java.io.IOException

getInputStream

public static java.io.InputStream getInputStream(java.lang.Object bluetoothSocket)
                                          throws java.io.IOException
Invokes the method android.bluetooth.BluetoothSocket#getInputStream.

Parameters:
bluetoothSocket - a android.bluetooth.BluetoothSocket object
Returns:
the InputStream
Throws:
java.io.IOException

getOutputStream

public static java.io.OutputStream getOutputStream(java.lang.Object bluetoothSocket)
                                            throws java.io.IOException
Invokes the method android.bluetooth.BluetoothSocket#getOutputStream.

Parameters:
bluetoothSocket - a android.bluetooth.BluetoothSocket object
Returns:
the OutputStream
Throws:
java.io.IOException

closeBluetoothSocket

public static void closeBluetoothSocket(java.lang.Object bluetoothSocket)
                                 throws java.io.IOException
Invokes the method android.bluetooth.BluetoothSocket#close.

Parameters:
bluetoothSocket - a android.bluetooth.BluetoothSocket object
Throws:
java.io.IOException