안녕하세요. 블루투스 검색이 안되어 아래와 같이 질문 드립니다.
코드<<===========================================
public class MainActivity extends AppCompatActivity {
BluetoothAdapter mBluetoothAdapter;
BroadcastReceiver mBroadcastReceiver;
IntentFilter mIntentFilter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter == null){Log.v("tag", "블루투스 사용 불가");}
else{
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
for(BluetoothDevice device : pairedDevices){}
if(mBluetoothAdapter.isEnabled()){
Log.v("tag", "블루투스 이네블");
mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e("tag", action);
}
};
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(BluetoothDevice.ACTION_FOUND);
mIntentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
mIntentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(mBroadcastReceiver, mIntentFilter);
mBluetoothAdapter.startDiscovery();
}
}
}
@Override
protected void onDestroy() {
unregisterReceiver(mBroadcastReceiver);
super.onDestroy();
}
}
===============================================================
위와 같이 간단하게 짰는데요.
String action = intent.getAction(); 의 코드에
ACTION_DISCOVERY_STARTED/FINISHED는 잘 들어와 LOG로 표시가 되는데
BluetoothDevice.ACTION_FOUND만 inetnet에 들어오지 않고 있습니다.
도대체 어떻게 해야하죠?