Question

This question is pretty much a duplicate but the linked issue was never really resolved and the thread is a few months old so I didn't want to resurrect it.

The default behavior of apps running on an ICS device with Android Beam turned on is to push a message with the application Uri that will be processed by Google Play on the receiving end.

I am trying to develop an activity that will push NdefMessage if condition A is true and will otherwise disable pushing messages. The API documentation for setNdefPushMessage(...) seems to indicate that this is possible by passing in a null message:

Pass a null NDEF message to disable foreground NDEF push in the specified activities.

However, trying to simply ban all pushes via the following code still results with the "Touch to Beam" UI coming up and an application Uri being sent...

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getNfcAdapter().setNdefPushMessage(null, this);
}

Does anyone know if it is actually possible to disable pushes from an Activity? A few systems apps do it but I have not been able to locate the code that achieves this. Any help is much appreciated.

Was it helpful?

Solution

This seems to be a bug in Android ICS. Although the documentation says you should be able to disable it by setting the NDEF message null, this simply does not work. Good news is that it has been fixed and now does work in Android 4.1 Jellybean.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top