ฉันกำลังพยายามจัดเก็บไฟล์ html ขนาดเล็กมาก (1K) ไว้ในแท็ก NFC เมื่ออ่านทางโทรศัพท์ ควรเรียกให้เบราว์เซอร์เปิดขึ้นมา
น่าเสียดายที่ฉันมีข้อจำกัดเหล่านั้น:
- ไฟล์ HTML (1kb) เก็บไว้ในแท็ก ไม่ใช่แค่ URL (ผู้ใช้ไม่มีอินเทอร์เน็ต)
- ไม่ใช่ข้อความ/ธรรมดา แต่ควรเป็นข้อความ/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>
ฉันทำอะไรผิดหรือเปล่า?
ขอบคุณ !