public class BluetoothReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
if (intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
Toast.makeText(context, "페어링 요청", 0).show();
try {
device.getClass().getMethod("setPairingConfirmation", boolean.class).invoke(device,true);
device.getClass().getMethod("cancelPairingUserInput", boolean.class).invoke(device);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
현재 리시버 등록해서 페어링요청시에 무언가 할수 있는 환경은 만들었는데,
구글링해서
device.getClass().getMethod("setPairingConfirmation", boolean.class).invoke(device,true);
device.getClass().getMethod("cancelPairingUserInput", boolean.class).invoke(device);
이 코드를 삽입하면 다이얼로그 안뜬다고 해서 넣어봤는데 되질 않네요..
자동페어링이 되지 않아도 됩니다.
다만 그냥 페어링 요청시에 사용자에게 알리는 다이얼로그, 소리 및 진동을 없애고 싶습니다.
어떻게 하면될까요 고수님들 ㅠㅠ 도와주세요!