Android Tutorial Reading NDEF data from NFC tags

NeoTechni

Well-Known Member
Licensed User
Longtime User
Im not trying to make an app to write data, the app i got the data from in the link already does that. Im trying to make an app to use the data.
The url is a placeholder, just to keep the code

When i scan a tag, my app does not show up in the list of apps that can receive the data
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
I can't create a tag, I'm trying to read the data on an existing one (it came out for a game recently)
 

ferdztech

Member
Licensed User
Longtime User
How to write/store data in NFC card. which version of NFC library support write method. I need to store data .
 

aeropic

Active Member
Licensed User
Longtime User
I'm playing around with NFC librairy and some tags.
It's amazing how simple it is to get it working. Many thanks for this librairy !

I'm trying to use it from a locked device. I hoped that the nfc tag could be read just when switching the screen on and that the NFC intent could wake up an activity to which I would give the "setshowwhenlocked" rights with the reflection
B4X:
Sub SetShowWhenLocked
   Dim r As Reflector
   r.Target = r.GetActivity
   r.Target = r.RunMethod("getWindow")
'  r.RunMethod2("addFlags", 6815872, "java.lang.int") 'combination of: FLAG_TURN_SCREEN_ON, FLAG_DISMISS_KEYGUARD, FLAG_SHOW_WHEN_LOCKED and FLAG_KEEP_SCREEN_ON.
   r.RunMethod2("addFlags", 2621440, "java.lang.int") 'combination of: FLAG_TURN_SCREEN_ON,  FLAG_SHOW_WHEN_LOCKED (API 5)
End Sub

But this does not work

Does anybody know a way to do it ?

Thanks
Alain
 

aeropic

Active Member
Licensed User
Longtime User
Thanks Erel for your answer.
Trying the first combination does not solve the problem
and when adding the line in the manifest I get a compile error :
B4X:
AndroidManifest.xml:22: error: No resource identifier found for attribute 'showOnLockScreen' in package 'android'
I do not know this attribute, how does it work ?

Nevertheless, I've the feeling NFC is blocked in the android system both during sleep and when screen is locked.
see http://www.androidauthority.com/galaxy-s3-i9300-nfc-lockscreen-screen-off-mod-125744/

XDA developpers have issued a mod working only on rooted phones...

The good news is that Lollipop is supposed to give more freedom to trusted devices (bluetooth but also NFC):
http://www.androidheadlines.com/201...th-nfc-nearby-automatic-device-unlocking.html
 

vincentehsu

Member
Licensed User
Longtime User
Dear All:
I've try this code via my Samsung Galaxy Note3
B4X:
If NFC.IsNdefIntent(Activity.GetStartingIntent) Then
      Dim records As List
      records = NFC.GetNdefRecords(Activity.GetStartingIntent)
      For i = 0 To records.Size - 1
         Dim r As NdefRecord
         r = records.Get(i)
         Log(r.GetAsTextType)
      Next
   End If

Why NFC.IsNdefIntent(Activity.GetStartingIntent) always false?
I use the quick pass credit card as my nfc tag,is this an NDEF tags?
 

wildfandango

Member
Licensed User
Longtime User

Hi Erel, one more time thx in advanc for this library...

How i can define a intent to capture the intent for reading EMPTY NFC "devices"?

i have tried

B4X:
AddActivityText(main, <intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <action android:name="android.nfc.action.TAG_DISCOVERED"/>
    <action android:name="android.nfc.action.TECH_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain"/>
</intent-filter>)

but not works...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…