Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid NFC not working with ICS
    primarykey
    data
    text
    <p>yesterday I watched Google IO Talk about NFC and today I'm trying to do some fun things with it.</p> <p>At the moment I've a Galaxy Nexus (ICS 4.0.2) and Nexus S (ICS 4.0.3). I've installed the sample application of that talk: <a href="http://nfc.android.com/StickyNotes.zip" rel="nofollow">http://nfc.android.com/StickyNotes.zip</a></p> <p>I'm also following this how-to in order to understand the flow with some comments: <a href="http://www.jessechen.net/blog/how-to-nfc-on-the-android-platform/" rel="nofollow">http://www.jessechen.net/blog/how-to-nfc-on-the-android-platform/</a></p> <p>What I'm trying to do is to send in p2p way a message from a phone to another and change the edittext content (like the example has to do!).</p> <p>I think that the NFC Message is going out but the other phone is not grabbing it... Someone know why?</p> <p>This is the logcat from one of the phone (when those 2 phones is contacting each other):</p> <pre><code>03-03 15:37:47.842: W/NFC-LLC(446): bad LLC length byte d0 03-03 15:37:47.842: W/NFC-LLC(446): bad LLC length byte a6 03-03 15:37:47.842: W/NFC-LLC(446): bad LLC length byte 42 03-03 15:37:47.842: W/NFC-LLC(446): bad LLC length byte 1 03-03 15:37:47.842: W/NFC-LLC(446): bad LLC length byte fc 03-03 15:37:47.842: W/NFC-LLC(446): bad LLC length byte c1 03-03 15:37:48.264: D/NFC JNI(446): Discovered P2P Target 03-03 15:37:48.264: D/NfcService(446): LLCP Activation message 03-03 15:37:48.264: D/NfcService(446): NativeP2pDevice.MODE_P2P_TARGET 03-03 15:37:48.296: I/NFC JNI(446): LLCP Link activated (LTO=150, MIU=128, OPTION=0x00, WKS=0x01) 03-03 15:37:48.296: D/NfcService(446): Initiator Activate LLCP OK 03-03 15:37:48.296: I/NfcP2pLinkManager(446): LLCP activated 03-03 15:37:48.296: D/NfcP2pLinkManager(446): onP2pInRange() 03-03 15:37:48.467: D/dalvikvm(446): GC_FOR_ALLOC freed 3192K, 18% free 17750K/21575K, paused 19ms 03-03 15:37:48.467: I/dalvikvm-heap(446): Grow heap (frag case) to 20.515MB for 3265936-byte allocation 03-03 15:37:48.514: D/dalvikvm(446): GC_CONCURRENT freed &lt;1K, 3% free 20939K/21575K, paused 4ms+3ms 03-03 15:37:51.264: I/NFC JNI(446): LLCP Link deactivated 03-03 15:37:51.264: D/NfcService(446): LLCP Link Deactivated message. Restart polling loop. 03-03 15:37:51.264: D/NfcService(446): disconnecting from target 03-03 15:37:51.264: I/NfcP2pLinkManager(446): LLCP deactivated. 03-03 15:37:52.022: D/NfcP2pLinkManager(446): Debounce timeout 03-03 15:37:52.022: D/NfcP2pLinkManager(446): onP2pOutOfRange() </code></pre> <p><strong>UPDATE</strong></p> <p>I've made some changes to default Sticky Notes code in order to upgrade it to support ICS NFC API. Infact if you go to the documentation you can see this: <a href="http://developer.android.com/reference/android/nfc/NfcAdapter.html#enableForegroundNdefPush%28android.app.Activity,%20android.nfc.NdefMessage%29" rel="nofollow">http://developer.android.com/reference/android/nfc/NfcAdapter.html#enableForegroundNdefPush%28android.app.Activity,%20android.nfc.NdefMessage%29</a></p> <p>This method is deprecated. use setNdefPushMessage(NdefMessage, Activity, Activity...) instead </p> <blockquote> <p>Strongly recommend to use the new setNdefPushMessage(NdefMessage, Activity, Activity...) instead: it automatically hooks into your activity life-cycle, so you do not need to call enable/disable in your onResume/onPause.</p> </blockquote> <p>Also I read this: For NDEF push to function properly the other NFC device <strong>must support</strong> either NFC Forum's <strong>SNEP</strong> (Simple Ndef Exchange Protocol), or Android's "<strong>com.android.npp</strong>" (Ndef Push Protocol). This was optional on Gingerbread level Android NFC devices, but <strong>SNEP is mandatory on Ice-Cream-Sandwich and beyond</strong>.</p> <p>I do not understand if using setNdefPushMessage it will automatically support SNEP protocol of if I have to make other changes. At the moment as I said I'm using a Galaxy Nexus (4.0.2) and a Nexus S (4.0.3) and I've no other kind of devices to makes tests. </p> <p>I've also implemented the onNdefPushComplete for the adapter that is sending messages and for what I can see its never called.. I don't understand if this is a problem about APIS, Devices, or my code. So what I don't understand is: if everything is working fine, when I change the text of the Sticky Note edit text and I link the 2 devices with NFC, the text will be sended to the other device? Is this the example?</p> <p>The really strange thing is that I cannot find examples about how to do NFC with ICS and the official documentation doesn't explain it so well...</p> <p>Someone know how to solve?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload