【发布时间】:2014-04-16 11:35:46
【问题描述】:
我正在尝试在 NFC 标签上存储一个非常小的 (1K) html 文件。 手机读取时,应触发浏览器打开。
遗憾的是,我有这些限制:
- HTML 文件 (1kb) 存储在标签上。不只是一个网址。(用户没有互联网)
- 不是 text/plain,应该是 text/html。
- 它应该由默认浏览器打开,而不是定制的应用程序。
我是这样创建标签的:
Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); NdefRecord record = NdefRecord.createMime( "text/html", "Hello world in <b>HTML</b> !"); NdefMessage message = new NdefMessage(new NdefRecord[] { record }); if (writeTag(message, detectedTag)) { Toast.makeText(this, "Success: Wrote placeid to nfc tag", Toast.LENGTH_LONG) .show(); }
但是由于某种原因,在读取标签时,默认浏览器没有打开。即使浏览器确实有正确的意图过滤器:
<!-- For these schemes where any of these particular MIME types have been supplied, we are a good candidate. --> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" /> <data android:scheme="https" /> <data android:mimeType="text/html"/> <data android:mimeType="text/plain"/> <data android:mimeType="application/xhtml+xml"/> <data android:mimeType="application/vnd.wap.xhtml+xml"/> </intent-filter>
我是不是做错了什么?
谢谢!
【问题讨论】: