BluetoothConnector.java 文件源码

java
阅读 46 收藏 0 点赞 0 评论 0

项目:LittleBitLouder 作者:
public FallbackBluetoothSocket(BluetoothSocket tmp, boolean isSecure) throws FallbackException {
    super(tmp);
    try {
        Class<?> clazz = tmp.getRemoteDevice().getClass();
        Class<?>[] paramTypes = new Class<?>[]{Integer.TYPE};

        String methodName = "createInsecureRfcommSocket";
        if (isSecure)
            methodName = "createRfcommSocket";

        Method m = clazz.getMethod(methodName, paramTypes);
        Object[] params = new Object[]{Integer.valueOf(1)};
        fallbackSocket = (BluetoothSocket) m.invoke(tmp.getRemoteDevice(), params);
    } catch (Exception e) {
        throw new FallbackException(e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号