NFC读取型动物活动标签全自动无问哪里处理标签 [英] NFC read TAGS in differents Activities automaticly without ask where process the TAGS

查看:208
本文介绍了NFC读取型动物活动标签全自动无问哪里处理标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读在不同Activites没有任何标记出现在我的显示屏,哪些活动是最适合读这个标签?我想这应该是自动的。 我的code清单是这样的:

I want to read in different Activites any TAG without appear in my display, what Activity is the best for read this tag? I think this should be automatic. My code manifest is this:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.iprocuratio.strim.LoginActivity"
        android:label="@string/title_activity_login" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.iprocuratio.strim.TemperatureActivity"
        android:label="@string/title_activity_temperature" >
    </activity>
    <activity
        android:name="com.iprocuratio.strim.ConstantsActivity"
        android:label="@string/title_activity_constants" >
    </activity>
    <activity
        android:name="com.iprocuratio.strim.FC"
        android:label="@string/title_activity_fc" >
    </activity>
    <activity
        android:name="com.iprocuratio.strim.FR"
        android:label="@string/title_activity_fr" >
    </activity>
    <activity
        android:name="com.iprocuratio.strim.SatO2"
        android:label="@string/title_activity_sat_o2" >
    </activity>
    <activity
        android:name="com.iprocuratio.strim.MainActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.iprocuratio.strim.PrescriptionsActivity"
        android:label="@string/title_activity_prescriptions">
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.iprocuratio.strim.MedicamentosActivity"
        android:label="@string/title_activity_medicamentos" >
    </activity>
    <activity
        android:name="com.iprocuratio.strim.Identificacion"
        android:label="@string/title_activity_identificacion" >
        <intent-filter >
            <action android:name="com.google.zxing.client.android.SCAN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.iprocuratio.strim.Pantallaleer"
        android:label="@string/title_activity_pantallaleer" >
        <intent-filter>
            <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.iprocuratio.strim.IdentificacionFinal"
        android:label="@string/title_activity_identificacion_final" >

    </activity>
</application>

我已经实现了读取标签中的两项活动: prescriptionsActivity和Pantallaleer。 例如,当我想读的prescriptionsActivity一个TAG总是出现下一个图像:

I have implemented the read the TAG in two activities: PrescriptionsActivity and Pantallaleer. For example, when I want to read a TAG in PrescriptionsActivity always appear the next image:

我想,当我读取标签不显示该窗口,并全自动选择正确的活动。 任何人都知道,我该怎么办? 难道我的code正确?

I would like that when I read the TAG it doesn't show this window and it automaticly choose the correct activity. Anyone know, how can I do? Is my code correct?

让我知道。谢谢你。

问候。

推荐答案

这两项活动都在同一个意向敏感(在包含文字实录标签(或即双触发类型文本的MIME类型的记录/平):

Both activities are sensitive on the same intent (i.e. both trigger on tags that contain a Text record (or a MIME type record of type text/plain):

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

这是不可能的Andr​​oid告诉一下活动将更好地适应需求,特定的标签,如果都包含相同的数据类型和两个过滤器匹配相同的数据类型。因此Android的显示的意图选择器让用户选择。

It's impossible for Android to tell what activity would better fit the needs for a specific tag if both contain the same data type and both filters match the same data type. Consequently Android shows the intent chooser to let the user select.

如果你想避免的意图选择器,你应该使用每个活动不同的数据类型(使用非常不具体text / plain的数据类型的欧洲工商管理学院)。例如,如果一个标签应启动 prescriptionsActivity ,你这样写NDEF消息标记:

If you want to avoid the intent chooser, you should use different data types for each activity (insead of using the very unspecific text/plain data type). For instance, if a tag should launch PrescriptionsActivity, you would write the following NDEF message to the tag:

+-------------------------------------------------+
| EXT:iprocuratio.com:prescriptions | <your data> |
+-------------------------------------------------+

您可以使用创建的Andr​​oid这个NDEF消息

You could create this NDEF message on Android using

NdefMessage msg = new NdefMessage(
    NdefRecord.createExternal("iprocuratio.com", "prescriptions", yourData),
);

意图过滤器 prescriptionsActivity 然后可以是这样的:

The intent filter for PrescriptionsActivity could then look like this:

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="vnd.android.nfc"
          android:host="ext"
          android:pathPrefix="/iprocuratio.com:prescriptions"/>
</intent-filter>

同样,对于 Pantallaleer 的活动,你可以使用:

Similarly, for the Pantallaleer activity, you could use:

+-------------------------------------------------+
| EXT:iprocuratio.com:pantallaleer | <your data> |
+-------------------------------------------------+

您可以使用创建的Andr​​oid这个NDEF消息

You could create this NDEF message on Android using

NdefMessage msg = new NdefMessage(
    NdefRecord.createExternal("iprocuratio.com", "pantallaleer", yourData),
);

意图过滤器 Pantallaleer 活动可能看起来像这样:

The intent filter for Pantallaleer activity could then look like this:

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="vnd.android.nfc"
          android:host="ext"
          android:pathPrefix="/iprocuratio.com:pantallaleer"/>
</intent-filter>

这篇关于NFC读取型动物活动标签全自动无问哪里处理标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆