question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Works on 4.2.x but no other operating system

See original GitHub issue

Hi,

So I’ve gotten this snippet to work on an android phone (Galaxy S3 running 4.1.2):

    nfc.addNdefListener (
        function (nfcEvent) {
            var text = document.querySelector('.writeEncoded'));
            var link = ndef.textRecord(text);
            nfc.write([link], function(){
                    alert('Success!');
                },
                function(){
                    alert('I\'m sorry, something went wrong, please try again');
                }
            );
        },
        function () { 
            alert("Waiting for NDEF tag");
        },
        function (error) {
            alert("Error adding NDEF listener " + JSON.stringify(error));
        }
    );

For some reason it doesn’t work on a Samsung Galaxy Tab 4 running 5.0.2, it also doesn’t work on a Nexus 7 running either 4.4.4 or 5.1.

Other information: the alert for successfully adding the listener is called, but when I touch my nfc tags (mifare classic and mifare ultralight) to the reader it only gives me a response on the phone. I’ve tested the readers and tags on the tablets, other apps can interact with the same tags.

Any direction would be much appreciated. Thank you

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MYoung25commented, Sep 30, 2016

Here is the logcat result from the tablet running 4.4.4

D/NfcDispatcher(  757): dispatch tag: TAG: Tech [android.nfc.tech.MifareUltralight, android.nfc.tech.NfcA, android.nfc.tech.Ndef] message: NdefMessage [NdefRecord tnf=1 type=54 payload=02656E32763570636E686D]
D/NfcPlugin( 5406): onPause Intent {  }
D/NfcPlugin( 5406): stopNfc
D/NfcDispatcher(  757): Set Foreground Dispatch
I/ActivityManager(  494): START u0 {act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras)} from pid -1
W/ActivityManager(  494): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
D/NfcPlugin( 5406): onNewIntent Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
I/NfcDispatcher(  757): matched TECH override
D/NfcPlugin( 5406): onResume Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
D/NfcDispatcher(  757): Set Foreground Dispatch
D/NfcPlugin( 5406): parseMessage Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
D/NfcPlugin( 5406): action android.nfc.action.TECH_DISCOVERED
D/NfcPlugin( 5406): android.nfc.tech.MifareUltralight
D/NfcPlugin( 5406): android.nfc.tech.NfcA
D/NfcPlugin( 5406): android.nfc.tech.Ndef
V/NfcPlugin( 5406): var e = document.createEvent('Events');
V/NfcPlugin( 5406): e.initEvent('ndef');
V/NfcPlugin( 5406): e.tag = {"isWritable":true,"id":[4,33,-51,-126,116,64,-127],"techTypes":["android.nfc.tech.MifareUltralight","android.nfc.tech.NfcA","android.nfc.tech.Ndef"],"type":"NFC Forum Type 2","canMakeReadOnly":true,"maxSize":137,"ndefMessage":[{"id":[],"type":[84],"payload":[2,101,110,50,118,53,112,99,110,104,109],"tnf":1}]};
V/NfcPlugin( 5406): document.dispatchEvent(e);
I/chromium( 5406): [INFO:CONSOLE(0)] "Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src * 'unsafe-inline'". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
I/chromium( 5406): ", source:  (0)
I/chromium( 5406): [INFO:CONSOLE(1070)] "Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src * 'unsafe-inline'".
I/chromium( 5406): ", source: file:///android_asset/www/cordova.js (1070)
D/NativeNfcTag(  757): Tag lost, restarting polling loop

and the logcat from 4.2.2

D/NfcDispatcher(  754): dispatch tag: TAG: Tech [android.nfc.tech.MifareUltralight, android.nfc.tech.NfcA, android.nfc.tech.Ndef] message: NdefMessage [NdefRecord tnf=1 type=54 payload=02656E32763570636E686D]
I/ActivityManager(  477): START u0 {act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras)} from pid -1
D/NfcPlugin( 5500): onPause Intent {  }
D/NfcPlugin( 5500): stopNfc
D/NfcDispatcher(  754): Set Foreground Dispatch
D/NfcPlugin( 5500): onNewIntent Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
W/ActivityManager(  477): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
D/NfcPlugin( 5500): onResume Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
D/NfcPlugin( 5500): parseMessage Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x24000000 cmp=org.ali75.form/.NFC_Form (has extras) }
D/NfcPlugin( 5500): action android.nfc.action.TECH_DISCOVERED
D/NfcPlugin( 5500): android.nfc.tech.MifareUltralight
D/NfcPlugin( 5500): android.nfc.tech.NfcA
D/NfcPlugin( 5500): android.nfc.tech.Ndef
V/NfcPlugin( 5500): var e = document.createEvent('Events');
V/NfcPlugin( 5500): e.initEvent('ndef');
V/NfcPlugin( 5500): e.tag = {"isWritable":true,"id":[4,33,-51,-126,116,64,-127],"techTypes":["android.nfc.tech.MifareUltralight","android.nfc.tech.NfcA","android.nfc.tech.Ndef"],"type":"NFC Forum Type 2","canMakeReadOnly":true,"maxSize":137,"ndefMessage":[{"id":[],"type":[84],"payload":[2,101,110,50,118,53,112,99,110,104,109],"tnf":1}]};
V/NfcPlugin( 5500): document.dispatchEvent(e);
D/NfcDispatcher(  754): Set Foreground Dispatch
I/NfcDispatcher(  754): matched TECH override
D/dalvikvm( 5500): GC_CONCURRENT freed 2214K, 23% free 8153K/10512K, paused 4ms+3ms, total 33ms
D/NativeNfcTag(  754): Tag lost, restarting polling loop
0reactions
doncommented, Jan 5, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

V8.4.2.x Configuration Limits and Restrictions for IBM ...
Property Hardware Type Maximum Number Control enclosures per system (cluster) FS5010/FS5015 1 Control enclosures per system (cluster) FS5030/F5035. FS5100 2 Control enclosures per system (cluster) FS5200...
Read more >
OpenSTEP 4.2 Doesn't Run with 4 - VT-x may be the Problem?
OS 4.2 worked flawlessly under Pllels 3.x. However, in Pllels 4.0, VT-x is turned on by default and can't be turned off. OS...
Read more >
Week 2 - 4.2.13 Quiz Results - Section Quiz Candidate: Date
Which operating system function has a steeper learning curve and can potentially break the system without careful use of its operations?
Read more >
Cisco ACI Virtualization Guide, Release 4.2(x)
One has the attribute VM Name, and the other has Operating System. A VM might match both uSeg EPGs. By default, Cisco APIC...
Read more >
Can't run electrum 4.2.0 on Windows 7 (api-ms-win-core-path ...
Yes, Electrum 4.1.5 runs on Windows 7 without any problems. I've tested this myself now. Documenting here for posterity. Testing with a fresh...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found