Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 从不同的活动中读取不同的nfc标签_Android_Nfc - Fatal编程技术网

Android 从不同的活动中读取不同的nfc标签

Android 从不同的活动中读取不同的nfc标签,android,nfc,Android,Nfc,目前,我有一个活动A成功地读取了一个标记的内容,但现在我应该能够从活动B读取另一个标记,这两个标记都是纯文本的,但活动A模拟了一个关于歌剧的标记的读取,而活动B必须模拟支付,因此用户在读取标记时应该已经在这些活动中 我在网上浏览过这方面的内容,但什么也没找到,而且我对nfc的技术还不够熟练,无法单独讨论这一点 提前感谢您的帮助,我认为不需要代码,因为它更像是一个理论问题,但我可以提供它 更具体地说,我使用Mifare Ultralight作为标记。最后我找到了一种方法来管理不同活动上的rad标记

目前,我有一个活动A成功地读取了一个标记的内容,但现在我应该能够从活动B读取另一个标记,这两个标记都是纯文本的,但活动A模拟了一个关于歌剧的标记的读取,而活动B必须模拟支付,因此用户在读取标记时应该已经在这些活动中

我在网上浏览过这方面的内容,但什么也没找到,而且我对nfc的技术还不够熟练,无法单独讨论这一点

提前感谢您的帮助,我认为不需要代码,因为它更像是一个理论问题,但我可以提供它


更具体地说,我使用Mifare Ultralight作为标记。

最后我找到了一种方法来管理不同活动上的rad标记


基本上,我必须在一个活动中实现一个前台调度器,然后从活动a和活动B扩展该活动,这样每个人只在foregorund上读取一个标记,并且系统选择器不会看到它。

我还做了类似的事情。有三种类型的NFC标签,如果用户扫描不同的NFC标签,我必须启动我的应用程序的不同活动。我玩了一会儿,但我想出了解决办法:

    <activity
        android:name=".ui.ProductInfo"
        android:label="Product Info:"
        android:screenOrientation="portrait">
        <intent-filter>

            <data android:mimeType="text/sbapp/info" />
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </activity>


    <activity
        android:name=".ui.ShoppingList"
        android:label="Shopping List:"
        android:screenOrientation="portrait">

        <intent-filter>
            <data android:mimeType="text/sbapp/buy" />
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </activity>

The NFC tags contained the following:
content type:
text /   sbapp/buy   (instead of text/plain)
data: 34345 (productID)

为什么不在两个活动中都有两个独立的前台调度?您可以在onDestroy方法中禁用前台分派
content type:
text /   sbapp/info   (instead of text/plain)
data: 34345 (productID)