我只想在单击按钮时阅读NFC

时间:2018-12-04 09:13:24

标签: android nfc

我遵循此link来从标签中读取NFC,但我成功了,但是问题是,我只想在单击按钮时才读取NFC。因此,在新的Intent中,我做到了

@Override
protected void onNewIntent(Intent intent) {
    /**
     * This method gets called, when a new Intent gets associated with the current activity instance.
     * Instead of creating a new activity, onNewIntent will be called. For more information have a look
     * at the documentation.
     *
     * In our case this method gets called, when the user attaches a Tag to the device.
     */
    readTag.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            bottomNavigationItemNFC.setVisibility(View.VISIBLE);
            handleIntent(intent);
        }
    });

}

但是在单击按钮之前,它仍在读取NFC标签。

这是我的首次发帖问题,如有任何错误,请原谅。谢谢

0 个答案:

没有答案