1

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 ? I have scoured the menus / preferences and can't find a way of doing this. The next step ... ICS source code :-/

Richard Green
  • 2,037
  • 2
  • 20
  • 38
  • 1
    You'll probably have better luck with this question on http://android.stackexchange.com. This of course assumes you haven't rooted your phone. – Marvin Pinto Jan 05 '12 at 14:19
  • Heh.. android.stackexchange.com said "go to stackoverflow.com"... Good job I can spot a recursion. Phone not rooted as I want to put this into the app for non-rooted phones... – Richard Green Jan 05 '12 at 15:11
  • What I was trying to get at was: If this option to turn off the tone really doesn't exist within the _regular_ settings (and you verified this on android.stackexchange.com), then there's a very good chance you won't be able to do it programatically. The rooted phone comment applies to the latter. – Marvin Pinto Jan 05 '12 at 15:23
  • FWIW. I have raised this on the android code base feature request list : http://code.google.com/p/android/issues/detail?id=24022 – Richard Green Jan 06 '12 at 12:00

3 Answers3

5

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()

  • Please read [answer] and provide the useful informations from the link in the answer. If the link dies, your answer becomes useless. – Jonathan Drapeau Jan 23 '14 at 12:57
4

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

public class MainActivity extends Activity implements ReaderCallback{
private NfcAdapter mNfcAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
}

@Override
public void onResume() {
    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);
}

@Override
public void onPause() {
    super.onPause();
    mNfcAdapter.disableReaderMode(this);
}

@Override
public void onTagDiscovered(Tag tag) {
    // Play your own sound here

    // Then handle your tag
}

}

jomalden
  • 403
  • 1
  • 4
  • 8
-1

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

robertly
  • 2,132
  • 14
  • 9
  • It's now possible, see https://stackoverflow.com/questions/36908374/android-nfc-enable-and-disable-the-nfc-detected-sounds – Sigi Jul 10 '18 at 03:13