Android examples for Bluetooth:Bluetooth State
get Method By Sdk for Bluetooth
//package com.java2s; import java.lang.reflect.Method; import android.bluetooth.BluetoothDevice; public class Main { static public Method getMethodBySdk(String release) throws SecurityException, NoSuchMethodException { String[] ss = release.split("\\."); StringBuilder sNum = new StringBuilder(); for (int i = 0; i < ss.length; i++) { sNum.append(ss[i]);/* ww w. j ava2s. c o m*/ } if (sNum.length() == 2) { sNum.append("0"); } int mSdkInt = Integer.parseInt(sNum.toString()); Method m = null; if (mSdkInt < 233) { m = BluetoothDevice.class.getMethod("createRfcommSocket", new Class[] { int.class }); } else { m = BluetoothDevice.class .getMethod("createInsecureRfcommSocket", new Class[] { int.class }); } return m; } }