隐藏“不支持NFC标签类型" Samsung Galaxy设备上的错误

隐藏“不支持NFC标签类型

问题描述:

我正在开发一个仅扫描MIFARE Classic卡的UID以促进出勤登记的应用程序.我有它的工作.但是,每次我在Galaxy S4上扫描卡时,都会吐司说不支持NFC标签类型".

I am working on an app that scans just the UID of MIFARE Classic cards to facilitate attendance registration. I have got it working. However, every time I scan a card on my Galaxy S4, I get a toast stating "NFC tag type not supported".

我想在应用打开时阻止或隐藏该消息.

I want to either block or hide that message while the app is open.

我注意到有

I noticed there was one other question asking for the same thing on a Galaxy S6 but it was down-voted once and then ignored.

我发现此对话,但是,我无法从那里写的内容中提取答案:

I found this conversation on the Samsung Developers forum, however, I could not extract an answer from what is written there:

  if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
      myTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); 
      tagID = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
      alertDialog.dismiss(); 

看起来好像是我需要的alertDialog.dismiss()部分,但是没有关于它们从何处获得alertDialog对象的说明.

It looks like the alertDialog.dismiss() section is what I need but there is no explanation for where they got the alertDialog object from.

Android 4.4之前的版本

您试图做的事根本不可能从应用程序中实现(至少不能在非根目录/未修改的设备上实现). Android系统(或更具体地说是NFC系统服务)在显示消息不支持NFC标签类型"之前,而不是将标签分发给您的应用.这意味着NFC系统服务会过滤MIFARE Classic标签,并且永远不会将其通知给任何应用程序.因此,您的应用无法检测到MIFARE Classic标签或绕过该弹出消息.

Before Android 4.4

What you are trying to do is simply not possible from an app (at least not on a non-rooted/non-modified device). The message "NFC tag type not supported" is displayed by the Android system (or more specifically the NFC system service) before and instead of dispatching the tag to your app. This means that the NFC system service filters MIFARE Classic tags and never notifies any app about them. Consequently, your app can't detect MIFARE Classic tags or circumvent that popup message.

在具有root用户权限的设备上,您可以使用任一方法绕过该消息

On a rooted device, you may be able to bypass the message using either

  1. 用于修改NFC服务的行为,或者
  2. 系统分区上的CSC(消费者软件自定义)功能配置文件(请参阅/system/csc/.如果CSC功能<CscFeature_NFC_EnableSecurityPromptPopup>为设置为"mifareclassic"或"all"以外的任何值.例如,您可以使用:

  1. Xposed to modify the behavior of the NFC service, or
  2. the CSC (Consumer Software Customization) feature configuration files on the system partition (see /system/csc/. The NFC system service disables the popup and dispatches MIFARE Classic tags to apps if the CSC feature <CscFeature_NFC_EnableSecurityPromptPopup> is set to any value but "mifareclassic" or "all". For instance, you could use:

<CscFeature_NFC_EnableSecurityPromptPopup>NONE</CscFeature_NFC_EnableSecurityPromptPopup>

您可以将此条目添加到例如文件"/system/csc/others.xml"(在该文件中已经存在的<FeatureSet> ... </FeatureSet>部分中).

You could add this entry to, for instance, the file "/system/csc/others.xml" (within the section <FeatureSet> ... </FeatureSet> that already exists in that file).

自此,您还询问了Galaxy S6(您链接的您所链接的问题):我已经测试了这种方法在S4上出来的时候我尚未验证这是否仍可在最新固件或其他设备(例如S6)上正常工作.

Since, you asked for the Galaxy S6 (the question that you linked) as well: I have tested this method on the S4 when it came out. I have not verified if this still works in the latest firmware or on other devices (e.g. the S6).

这纯粹是猜测,但 请参阅NfcAdapter.enableReaderMode ),可能与

This is pure guessing, but according to this (link no longer available), it seems that some apps (e.g. NXP TagInfo) are capable of detecting MIFARE Classic tags on affected Samsung devices since Android 4.4. This might mean that foreground apps are capable of bypassing that popup using the reader-mode API (see NfcAdapter.enableReaderMode) possibly in combination with NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK.