device.getName()
을 사용하는 데 약간의 문제가 있습니다. 그것은 내 응용 프로그램을 충돌시키는 원인이됩니다.Android 블루투스 충돌 응용 프로그램
내가하고있는 일은 대화 상자에 어댑터 (블루투스 이름 보유)를 표시하는 것입니다. 응용 프로그램을 실행하고 - .getName()
대신 device.getAdress()
을 추가하면 응용 프로그램이 제대로 작동하지만 .getName()
을 실행하면 응용 프로그램이 중단됩니다.
mBluetoothAdapter.startDiscovery();
receiver = 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);
toothadapter.add(device.getName());
toothadapter.notifyDataSetChanged();
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(bluetooth.this);
builder.setTitle("Nearby Devices:");
builder.setAdapter(toothadapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
}
});
AlertDialog alert = builder.create();
alert.show();
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(receiver, filter);
왜 이런 일이 발생하는지에 대한 도움이 필요합니다. 위의 코드는 buttonListener
내에 onCreate()
에 모두 포함되어 있습니다.
'toothadapter'의 유형은 무엇입니까? – Onik
toothadapter = new ArrayAdapter (bluetooth.this, android.R.layout.select_dialog_item); –
그게 문제의 주요 부분이고, 디버깅을 할 때 s7 가장자리를 잡을 수 없으며 기계가 가지고 있지 않기 때문에 bt를 에뮬레이트 할 수 없습니다.- –