扫描/识别 NFC 意图时防止发出警报音

发布于 2024-12-25 11:01:35 字数 128 浏览 3 评论 0原文

也许我遗漏了一些东西,但是当我通过 Galaxy Nexus 扫描 NFC 标签时,手机总是发出默认的警报音。

有没有办法以编程方式关闭此功能?我已经搜索了菜单/首选项,但找不到执行此操作的方法。下一步...ICS源代码:-/

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 :-/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

围归者 2025-01-01 11:01:36

以下是如何静音/更改 nfc 声音的简单示例

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
}

}

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
}

}

荒路情人 2025-01-01 11:01:36

没有办法以编程方式关闭此声音或覆盖 Touch to Beam UI。

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

你列表最软的妹 2025-01-01 11:01:35

使用 android-19,您可以:

如以下所述:
http://developer.android.com/reference/android/nfc/NfcAdapter .html#FLAG_READER_NO_PLATFORM_SOUNDS

通过使用 NfcAdapter.enableReaderMode() 和标志FLAG_READER_NO_PLATFORM_SOUNDS 而不是 NfcAdapter.enableForegroundDispatch()

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文