- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
第一次,我想为项目 WinPhone 和 Android 实现 NFC 跨平台 Xamarin.Forms。
我在 Android 上测试我的应用程序,但实际上没有任何反应。作为工具,我使用了我在 Android 程序 reTag 中测试过的 Visa Pay Wave 卡,扫描成功。我使用了来自这个 link 的 GitHub 的解决方案我有 0 个错误,应用程序也“有效”,但是当我将我的 Visa 卡添加到手机背面时,我什么也没得到。
我的第一个问题是:哪种协议(protocol)使用 Visa 卡? (TAG_DISCOVERED、TECH_DISCOVERED 或 NDEF_DISCOVERED)。我认为这是我的程序处于“空闲”状态的原因。
我的第二个问题是:你知道为什么我无法从程序中获取任何事件吗? (开始只是获取 UID 号..)
这是我的 AndroidManifest.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.NFC" />
<application android:label="NFCTest002.Android"></application>
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<application>
<activity
android:name="MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc" />
</activity>
</application>
</manifest>
我的 MainActivity.cs:
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Nfc;
using Android.OS;
using Poz1.NFCForms.Abstract;
using Poz1.NFCForms.Droid;
using System;
namespace NFCTest002.Droid
{
[Activity(Label = "NFCTest002", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { NfcAdapter.ActionTechDiscovered })]
[MetaData(NfcAdapter.ActionTechDiscovered, Resource = "@xml/nfc")]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
public NfcAdapter NFCdevice;
public NfcForms x;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
NfcManager NfcManager = (NfcManager)Android.App.Application.Context.GetSystemService(Context.NfcService);
NFCdevice = NfcManager.DefaultAdapter;
Xamarin.Forms.DependencyService.Register<INfcForms, NfcForms>();
x = Xamarin.Forms.DependencyService.Get<INfcForms>() as NfcForms;
LoadApplication(new NFCTest002.App());
}
protected override void OnResume()
{
base.OnResume();
if (NFCdevice != null)
{
var intent = new Intent(this, GetType()).AddFlags(ActivityFlags.SingleTop);
NFCdevice.EnableForegroundDispatch
(
this,
PendingIntent.GetActivity(this, 0, intent, 0),
new[] { new IntentFilter(NfcAdapter.ActionTechDiscovered) },
new String[][] {new string[] {
NFCTechs.Ndef,
},
new string[] {
NFCTechs.MifareClassic,
},
}
);
}
}
protected override void OnPause()
{
base.OnPause();
NFCdevice.DisableForegroundDispatch(this);
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
x.OnNewIntent(this, intent);
}
}
}
我已经将 nfc.xml 文件添加到 Resource 文件夹和 xml 文件夹,如果需要我会发布它。
内容页面与我提供的链接中 GitHub 上的相同。
最佳答案
Visa payWave 卡基于 EMV 标准。在 RF 通信协议(protocol)方面,这些卡使用 ISO/IEC 7816-4 over ISO-DEP (ISO/IEC 14443-4)。
在 Android 上,您可以结合使用 TECH_DISCOVERED Intent 过滤器和适当的过滤器 XML 文件来获取这些卡片。对于这些卡片,XML 文件需要如下所示:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
</tech-list>
</resources>
与上述基于 list 的 Intent 过滤器的方法类似,您可以使用以下方法启用基于前台调度的标签发现:
NFCdevice.EnableForegroundDispatch(
this,
PendingIntent.GetActivity(this, 0, intent, 0),
new[] { new IntentFilter(NfcAdapter.ActionTechDiscovered) },
new String[][] {
new string[] {
NFCTechs.IsoDep,
},
}
);
NDEF_DISCOVERED Intent 过滤器不适用于 EMV 卡,因为它们不包含任何 NDEF 结构化数据。
关于android - NFC 与 Xamarin.Forms 没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43945777/
我的设置.py: LANGUAGE_CODE = 'de' TIME_ZONE = require_env("TIME_ZONE_IDENTIFIER") USE_I18N = True USE_L1
谁能给我解释一下 Django 的 forms.Form 和 forms.ModelForm 的相同点和不同点? 最佳答案 从 forms.Form 创建的表单由您手动配置。您最好将这些用于不直接与模
我在用 angularjs 构建的表单上遇到此错误。 `错误:[$compile:multidir] 多个指令 [form, form] 请求 'form' Controller :
我是 Spring 的新手,在尝试显示表单错误时遇到了一些麻烦。 我有以下表格: User Name:
我希望在提交表单时找出 spring:bind 和 form:form 标记库之间的区别。 我的 JSP 片段如下: ....
类型‘AbstractControl’上不存在属性‘Controls’。
有一个问题与此非常相似,但我想以不同的方式提出。 我是一个非常自定的人,但有时我确实喜欢走捷径。就这样吧。 我确实发现这两个类非常相似,尽管其中一个“帮助”程序员更快地编写代码或减少代码/重复代码。将
我在控制台中收到此错误。 “表单提交已取消,因为表单未连接” 自从我们将应用程序迁移到更新版本的 React 后,尝试将我的 redux-form 从 v5 迁移到 v6 之后。 我不确定这里出了什么
我想要的是一个表单,在提交时运行验证检查,并突出显示所有无效字段并添加工具提示。 我正在有效地寻找这样的东西: dojo.forEach(dijit.byId('myForm')._invalidWi
我需要设置symfony2表单元素的值。 我在 Controller 操作中使用了doctrine2实体, Symfony\Component\Form\AbstractType 和createFor
这是用于将数据提交到自定义列表的自定义 Editform.aspx。用户完成表单后,他应该能够点击按钮甚至“确定”按钮,并让 sharepoint 将表单数据提交到列表,然后重定向到项目显示表单 (d
我想知道在 spring 标签中编写所有表单是否是一种好习惯,或者我可以将 spring 表单标签与 html 表单标签混合使用吗? 最佳答案 当您需要 Spring 表单提供的功能时使用它们: 绑定
我正在构建动态表单并希望“即时”添加表单组。 这是我的代码,几乎可以工作: import {Component, OnInit} from '@angular/core'; import {FormG
表格 Form.Load 有什么区别? , Form.Shown和 Form.Activated事件?他们被解雇的顺序是什么? 最佳答案 参见 Windows Forms Events Lifecyc
我正在使用具有路线跟踪功能的 Xamarin Forms 开发一些应用程序。尽管我正在使用 AppCenter,即在 App.xaml.cs OnStart 我添加 protected asy
我正在实现一个 gameboy 模拟器,就像我之前的许多人一样。 我正在尝试实现 PPU 并为此使用代表屏幕的类。 // needed because VS can't find it as depe
我是 Orbeon Form 新手,想使用它。不过,我尝试过 Orbeon Form 网站上的 Form 示例,并用泰语输入了一些数据。是的,可以在“泰语”字段中输入数据。但是当我尝试生成“PDF”时
那么让表单一遍又一遍有效地呈现相同表单的最佳方法是什么,并根据实体的属性值有条件地禁用字段? 我有一个发票实体,需要一个用于创建发票的表单,以及在发票流程的各个阶段(生成、发送、支付等)禁用各个字段的
因此,我一直在与我的同事(开发人员和设计人员)就 Web 表单的自动填充工具进行亲切的辩论。这是一个重要的开发问题,因为它会影响表单的构建方式。 问)自动填充工具(例如 Google 工具栏或 Chr
那么让表单一遍又一遍有效地呈现相同表单的最佳方法是什么,并根据实体的属性值有条件地禁用字段? 我有一个发票实体,需要一个用于创建发票的表单,以及在发票流程的各个阶段(生成、发送、支付等)禁用各个字段的
我是一名优秀的程序员,十分优秀!