Android BT扫描(无法在文本视图中显示)
是否确实调用了onReceive函数?尝试在内部打印一些调试文本 如果调用它,请尝试添加Android BT扫描(无法在文本视图中显示),android,Android,是否确实调用了onReceive函数?尝试在内部打印一些调试文本 如果调用它,请尝试添加 final BroadcastReceiver ActionFoundReceiver1 = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if(BluetoothD
final BroadcastReceiver ActionFoundReceiver1 = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
out = (TextView) findViewById (R.id.deviceName);
out.setText(device.getName());
btDeviceList.add(device);
}
}
}
您的问题是什么?当我打开应用程序并进行扫描时,它在我的文本视图中没有显示任何内容。@Cindy2011,请编辑您的原始问题并包含必要的信息。
out = (TextView) findViewById (R.id.deviceName);
out.setText(device.getName());
out.invalidate(); // Add this