Eventhough I still miss some more debugging results from the OP, I thought I'd give it a shot:
As the discussion in the commands revealed that the createNdefMessage
callback is not called when interacting with a WP8 phone, it would be interesting why this appens and how to prevent this. Unfortunately I have no details about the actual lifecycle of the activity, so I can only guess what might go wrong.
One reason why a registered createNdefMessage
callback may not be called is that the activity that registered the callback is no longer in the foreground. So there may be a difference between an Android device and a WP8 device that causes the current activity to be paused.
Another reason would be that the WP8 device interupts communication before the Android NFC stack had the time to call the createNdefMessage
callback method. However, this should be detectable as the Beam UI would typically disappear before the user is able to click it.
One cause for reason 1 may be that the WP8 device itself sends an NDEF message that causes intent processing on the Android device. If that's the case, a method to overcome this problem may be to register for the foreground dispatch system. This would prevent regular intent processing and would directly send all incoming NDEF messages to the current activity:
@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.");
}
}
}
NdefRecord uriRecord = NdefRecord.createUri(webView.getUrl());
with the webView having been pointed to a website (not the play store) in the activity's onCreate. What WP8 sees is the URL mentioned in the question – ReviscreateNdefMessage
callback is actually called (e.g. by adding logging)? – YseultesetNdefPushMessage
to set a static NDEF message instead of creating one dynamically using the callback? (Note that you must not register a callback withsetNdefPushMessageCallback
in that case!) – YseultesetBeamPushUris
orsetBeamPushUrisCallback
, right? – YseultecreateNdefMessage
is called when beaming to Android, but not called when beaming to WP8. What could the reason be? – DiscountNfcP2pLinkManager
(again for both android-to-android and android-to-wp8)? – Yseulte