我能够配对蓝牙键盘但无法连接以使其成为输入设备.我浏览了开发者网站提供的文档 - http://developer.android.com/guide/topics/connectivity/bluetooth.html#Profiles
它表示Android蓝牙API提供以下蓝牙配置文件的实现,但您可以实现接口BluetoothProfile编写自己的类以支持特定的蓝牙配置文件.
没有关于如何为HID蓝牙设备(键盘)实现BluetoothProfile的文档
Android本身已经为HID设备实现了蓝牙连接,但这些API是隐藏的.我也试过反思来使用它们.我没有得到任何错误,但键盘没有作为输入设备连接.这就是我所做的 -
private void connect(final BluetoothDevice bluetoothDevice) {
if(bluetoothDevice.getBluetoothClass().getDeviceClass() == 1344){
final BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothProfile.ServiceListener mProfileListener = new BluetoothProfile.ServiceListener() {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
Log.i("btclass", profile + "");
if (profile == getInputDeviceHiddenConstant()) {
Class instance = null;
try {
//instance = Class.forName("android.bluetooth.IBluetoothInputDevice");
instance = Class.forName("android.bluetooth.BluetoothInputDevice");
Method connect = instance.getDeclaredMethod("connect", BluetoothDevice.class);
Object value = connect.invoke(proxy, bluetoothDevice);
Log.e("btclass", value.toString());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InvocationTargetException …Run Code Online (Sandbox Code Playgroud) 实际上,当任何其他应用程序从我的应用程序共享的内容提供程序中获取数据时,我想要某种广播
我有表示问题RecyclerView用StaggeredGridLayoutManager其项包含一个imageview和所述图像中装入imageview使用glide.我面临的问题是,在图像加载后,它们不会交错并且尺寸相同,两列之间也存在很大的差距.如何在列中没有间隙的情况下改变图像的高度?
android staggered-gridview staggeredgridlayout android-recyclerview android-glide