Despite the fact that I'm still missing some debugging results from the OP, I thought I would give it a shot:
As discussed in the commands, it turned out that the createNdefMessage not called when interacting with the WP8 phone, it would be interesting why this adds and how to prevent it. Unfortunately, I have no details about the actual life cycle of the activity, so I can only guess what might go wrong.
One of the reasons why the registered createNdefMessage cannot be called is because the activity that registered the callback is no longer in the foreground. Thus, there may be a difference between the Android device and the WP8 device, which forces you to pause current activity.
Another reason is that the WP8 device intercepts the connection before the Android NFC stack has managed to call the createNdefMessage callback method. However, this should be detected, as the Beam user interface usually disappears before the user can click it.
One of the reasons why there may be reason 1 may be that the WP8 device itself sends an NDEF message that causes intent processing on the Android device. In this case, a method to overcome this problem may be to register for the foreground dispatching system. This would prevent regular processing of intentions and directly send all incoming NDEF messages to ongoing activities:
@Override public void onResume() { super.onResume(); NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); adapter.enableForegroundDispatch(this, pi, null, null); } @Override public void onNewIntent(Intent intent) { if (intent != null) { String action = intent.getAction(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action) || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) { Log.d("NdefTest", "This problem was actually caused by an incoming NDEF message."); } } }
Michael Roland
source share