/ Published in: Java
You need to create a new package android.bluetooth in your project, and add the files: IBluetooth.aidl y IBluetoothCallback.aidl from the android source code
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private IBluetooth getIBluetooth() { IBluetooth ibt = null; try { Class c2 = Class.forName("android.os.ServiceManager"); IBinder b = (IBinder) m2.invoke(null, "bluetooth"); Class c3 = Class.forName("android.bluetooth.IBluetooth"); Class[] s2 = c3.getDeclaredClasses(); Class c = s2[0]; m.setAccessible(true); ibt = (IBluetooth) m.invoke(null, b); Log.e(TAG, "Erroraco!!! " + e.getMessage()); } return ibt; } /************************ IBluetooth.aidl ************************/ package android.bluetooth; import android.bluetooth.IBluetoothCallback; import android.os.ParcelUuid; /** * System private API for talking with the Bluetooth service. * * {@hide} */ interface IBluetooth { boolean isEnabled(); int getBluetoothState(); boolean enable(); boolean disable(boolean persistSetting); int getScanMode(); boolean setScanMode(int mode, int duration); int getDiscoverableTimeout(); boolean setDiscoverableTimeout(int timeout); boolean startDiscovery(); boolean cancelDiscovery(); boolean isDiscovering(); void removeServiceRecord(int handle); } /************************ IBluetoothCallback.aidl ************************/ package android.bluetooth; /** * System private API for Bluetooth service callbacks. * * {@hide} */ interface IBluetoothCallback { void onRfcommChannelFound(int channel); }