Skip to content Skip to sidebar Skip to footer

Prevent Alert Tone When Scanning / Identifying An Nfc Intent

Perhaps I'm missing something but when I scan an NFC tag via a galaxy nexus, the phone always makes the default alert tone. Is there a way of programmatically switching this off ?

Solution 1:

with android-19 you can:

as described in: http://developer.android.com/reference/android/nfc/NfcAdapter.html#FLAG_READER_NO_PLATFORM_SOUNDS

By using NfcAdapter.enableReaderMode() and the flag FLAG_READER_NO_PLATFORM_SOUNDS instead of NfcAdapter.enableForegroundDispatch()

Solution 2:

Here is a simple example of how to silence/change nfc sounds

publicclassMainActivityextendsActivityimplementsReaderCallback{
privateNfcAdapter mNfcAdapter;

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
}

@OverridepublicvoidonResume() {
    super.onResume();
    // This example works using using simple mifare ultralight tags. Set any necessary flags for other tags 
    mNfcAdapter.enableReaderMode(this, this, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS, null);
}

@OverridepublicvoidonPause() {
    super.onPause();
    mNfcAdapter.disableReaderMode(this);
}

@OverridepublicvoidonTagDiscovered(Tag tag) {
    // Play your own sound here// Then handle your tag
}

}

Solution 3:

There isn't a way to pro grammatically turn this sound off or to override the Touch to Beam UI.

Post a Comment for "Prevent Alert Tone When Scanning / Identifying An Nfc Intent"