3
我有下面的代码:ACTION_DISCOVERY_STARTED从来没有所谓的Android
public class AddPrinter extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
bluetoothAdapter.startDiscovery();
filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(receiver, filter);
}
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
System.out.println(action);
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
adapter.add(device);
}
else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(intent.getAction())) {
System.out.println("STARTED");
}
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(intent.getAction())) {
Utils.dialog.dismiss();
}
}
};
我的问题是如此怪异,由于某种原因,ACTION_DISCOVERY_STARTED永远不会被调用,但所有其他操作都很好,我失去了什么?感谢您的时间。
名称确保ü已<用途的许可安卓:名称= “android.permission.BLUETOOTH_ADMIN”/>后 <使用许可权的android:名称=“android.permission.BLUETOOTH”/>在显示中? –
是的,我有 –