android蓝牙取消已配对,如何在Android 2.1中取消配对蓝牙设备sdk

本文深入解析了Android系统中蓝牙服务接口IBluetooth的实现原理及使用方法。通过源码级的剖析,介绍了如何获取蓝牙服务、开启关闭蓝牙等功能,并详细解释了如设备配对、远程设备信息获取等操作的具体实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

创建文件)方法调用getBluetooth( private IBluetooth getIBluetooth() {

IBluetooth ibt = null;

try {

Class c2 = Class.forName("android.os.ServiceManager");

Method m2 = c2.getDeclaredMethod("getService",String.class);

IBinder b = (IBinder) m2.invoke(null, "bluetooth");

Class c3 = Class.forName("android.bluetooth.IBluetooth");

Class[] s2 = c3.getDeclaredClasses();

Class c = s2[0];

Method m = c.getDeclaredMethod("asInterface",IBinder.class);

m.setAccessible(true);

ibt = (IBluetooth) m.invoke(null, b);

} catch (Exception e) {

Log.e("flowlab", "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);

String getAddress();

String getName();

boolean setName(in String name);

int getScanMode();

boolean setScanMode(int mode, int duration);

int getDiscoverableTimeout();

boolean setDiscoverableTimeout(int timeout);

boolean startDiscovery();

boolean cancelDiscovery();

boolean isDiscovering();

boolean createBond(in String address);

boolean cancelBondProcess(in String address);

boolean removeBond(in String address);

String[] listBonds();

int getBondState(in String address);

String getRemoteName(in String address);

int getRemoteClass(in String address);

ParcelUuid[] getRemoteUuids(in String address);

boolean fetchRemoteUuids(in String address, in ParcelUuid uuid, in IBluetoothCallback callback);

int getRemoteServiceChannel(in String address, in ParcelUuid uuid);

boolean setPin(in String address, in byte[] pin);

boolean setPasskey(in String address, int passkey);

boolean setPairingConfirmation(in String address, boolean confirm);

boolean cancelPairingUserInput(in String address);

boolean setTrust(in String address, in boolean value);

boolean getTrustState(in String address);

int addRfcommServiceRecord(in String serviceName, in ParcelUuid uuid, int channel, IBinder b);

void removeServiceRecord(int handle);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值