How to read NFC tag data globally inside an Android Application -
I would like to read NFC tag data inside my application. Basically I have different NFC tags associated with different actions that perform inside my application. It's a bad idea to declare me Here I appear: Here is my service class: I did not receive the call within the You can not obtain NFC discovery intents ( A trick that you can use, is to use an invisible / transparent activity to handle the intent intent filter inside
service I do not want to associate it with any
activity .
& lt; service android: name = "com .yo.helpers.NFCReaderHelper" Android: Enabled = "True" Android: export = "true" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.nfc.action.NDEF_DISCOVERED" /> & Lt; Category android: name = "android.intent.category.DEFAULT" /> & Lt; Data Android: scheme = "http" /> & Lt; / Intent-Filter & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "android.nfc.action.NDEF_DISCOVERED" /> & Lt; Category android: name = "android.intent.category.DEFAULT" /> & Lt; Data Android: mimeType = "text / plain" /> & Lt; / Intent-Filter & gt; & Lt; / Services & gt;
@override protected void handelist (intent to intent) {Log D ("योओ", "service") ; Tag mTag = null; If (intent.getAction ()! = Null) {if (intent.getAction (.) Equals ("android.nfc.action.NDEF_DISCOVERED")) log D. ("Yo", "Intention Call"); MTag = (tag) intent.getParcelableExtra (NfcAdapter.EXTRA_TAG); Logs. I ("tag id", bytefxstring (mTag.getId ()); }}
onHandleIntent method. If I do this within a
activity , then I get intent within the
onNewIntent method
NDEF_DISCOVERED ,
TECH_DISCOVERED with a service (or a broadcast receiver) ,
TAG_DISCOVERED ) On Android, NFC is designed as a means of interacting with the user and therefore, these intentions are distributed only on the activities Has been played.
Comments
Post a Comment