List of usage examples for android.bluetooth BluetoothDevice getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static void setPairingConfirmation(BluetoothDevice device) throws Exception { device.getClass().getMethod("setPairingConfirmation", boolean.class).invoke(device, true); }
From source file:Main.java
public static void unpairDevice(BluetoothDevice device) { try {/* w ww.j av a 2 s . com*/ Method m = device.getClass().getMethod("removeBond", (Class[]) null); m.invoke(device, (Object[]) null); } catch (Exception e) { Log.d("BlueUtils", e.getMessage()); } }
From source file:Main.java
public static final Boolean createBond(BluetoothDevice device) { try {//w w w . ja v a 2s. c om Method m1 = device.getClass().getMethod("createBond", new Class[] {}); return (Boolean) m1.invoke(device); } catch (Exception e) { return null; } }
From source file:Main.java
public static boolean createBond(BluetoothDevice device) throws Exception { Method createBondMethod = device.getClass().getMethod("createBond"); return (Boolean) createBondMethod.invoke(device); }
From source file:Main.java
public static boolean unPair(BluetoothDevice device) throws Exception { Method removeBondMethod = device.getClass().getMethod("removeBond"); return (Boolean) removeBondMethod.invoke(device); }
From source file:Main.java
public static boolean cancelPairingUserInput(BluetoothDevice device) throws Exception { Method createBondMethod = device.getClass().getMethod("cancelPairingUserInput"); Boolean returnValue = (Boolean) createBondMethod.invoke(device); return returnValue.booleanValue(); }
From source file:Main.java
public static boolean setPin(BluetoothDevice device, String str) throws Exception { Method setPinMethod = device.getClass().getMethod("setPin", new Class[] { byte[].class }); return (Boolean) setPinMethod.invoke(device, new Object[] { str.getBytes() }); }
From source file:Main.java
public static boolean cancelPairingUserInput(BluetoothDevice device) throws Exception { Method cancelPairingUserInputMethod = device.getClass().getMethod("cancelPairingUserInput"); return (Boolean) cancelPairingUserInputMethod.invoke(device, true); }
From source file:Main.java
/** * see http://habrahabr.ru/post/144547///from w ww . j a v a 2s . c o m */ public static BluetoothSocket createRfcommSocket(BluetoothDevice device) { BluetoothSocket tmp = null; try { Class class1 = device.getClass(); Class aclass[] = new Class[1]; aclass[0] = Integer.TYPE; Method method = class1.getMethod("createRfcommSocket", aclass); Object aobj[] = new Object[1]; aobj[0] = Integer.valueOf(1); tmp = (BluetoothSocket) method.invoke(device, aobj); } catch (NoSuchMethodException e) { e.printStackTrace(); if (D) Log.e(TAG, "createRfcommSocket() failed", e); } catch (InvocationTargetException e) { e.printStackTrace(); if (D) Log.e(TAG, "createRfcommSocket() failed", e); } catch (IllegalAccessException e) { e.printStackTrace(); if (D) Log.e(TAG, "createRfcommSocket() failed", e); } return tmp; }
From source file:Main.java
private static synchronized BluetoothSocket getInsecureRfcommSocketByReflection(BluetoothDevice device) throws Exception { if (device == null) return null; Method m = device.getClass().getMethod("createInsecureRfcommSocket", new Class[] { int.class }); return (BluetoothSocket) m.invoke(device, 1); }