zoukankan      html  css  js  c++  java
  • Android Studio NFC 读写卡程序 (一)

    最近要做一个RFID 相关的项目,具体是关于 13.56MHz 的 NFC 卡的读写程序。

     1.NFC 常用场景 是 读卡,写卡 ,分享内容。 读写卡 主要 有两种  NDEF 读写模式 和 非 NDEF 读写模式

     2. 非NDEF  包含以下 常见数据格式:NfcA/NfcB/NfcF/NfcV/IsoDep/Ndef,意思是如果采用了不同的芯片(选用的标准不同,不同解决方案,) 卡的数据格式不同。

          就是 通过 techlist 设置 的选项,获取 通过  Tag.getTechlist()。

     3.     常见的 3种NFC相应程序(每种应用程序的启动页就是一个activity),分别对应三种过滤器,那么当一个tag靠近时,nexus s究竟选择哪种应用程序来处理呢?按照以下的          规 则,该规则成为intent发布系统规则:       

             activity 1中对intent过滤器设置了Android.nfc.action.NDEF_DISCOVERED的判断规则;

    <intent-filter>
        <action android:name = "android.nfc.action.NDEF_DISCOVERED" />
        <data android:mimeType = "text/plain" />
    </intent-filter>
    

      activity 2中对intent过滤器设置了android.nfc.action.TECH_DISCOVERED的判断规则;

    <intent-filter>             
            <action android:name="android.nfc.action.TECH_DISCOVERED" />
        </intent-filter> 
       <meta-data android:name="android.nfc.action.TECH_DISCOVERED"
              android:resource="@xml/filter_nfc" /> 

        activity 3中对intent过滤器设置了android.nfc.action.TAG_DISCOVERED的判断规则;

    <intent-filter>
           <action android:name="android.nfc.action.TAG_DISCOVERED"/>
           <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
    

      按照优先级:最高的是 activity 1,第二是 activity2,第三是 activity3,当优先级 高的不满足条件时,才会进行第二个。

       NDEF,TECH,TAG,    TECH 需要 自己配置额外的xml 过滤。

  • 相关阅读:
    Toolbar设置回退箭头的方法
    Android进程绝杀技--forceStop
    线程池的经典使用
    Handler+ExecutorService(线程池)+MessageQueue模式+缓存模式
    adb pull apk
    工厂模式_工厂方法模式
    工厂模式_简单工厂模式
    spring_aop
    代理模式_动态代理
    代理模式_静态代理
  • 原文地址:https://www.cnblogs.com/lfyy/p/7028843.html
Copyright © 2011-2022 走看看