80,448
社区成员




private final BluetoothProfile.ServiceListener connect = new BluetoothProfile.ServiceListener() { @Override public void onServiceConnected(int profile, BluetoothProfile proxy) { //BluetoothProfile proxy这个已经是BluetoothInputDevice类型了 try { proxys = proxy; if (device != null) { Method method = proxy.getClass().getDeclaredMethod("connect"); method.invoke(device); } } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } @Override public void onServiceDisconnected(int profile) { } };
反射获取 connect 方法时,报错:java.lang.NoSuchMethodException: android.bluetooth.BluetoothHidHost.connect []