Reputation: 2062
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 :-/
Upvotes: 2
Views: 7014
Reputation: 403
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
}
}
Upvotes: 4
Reputation: 177
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()
Upvotes: 6
Reputation: 2132
There isn't a way to pro grammatically turn this sound off or to override the Touch to Beam UI.
Upvotes: -1