chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 557 forks source link

Android: Exception on write: android.os.Parcelable on a null object reference #232

Closed mobidev111 closed 8 years ago

mobidev111 commented 8 years ago

Plugin version: 0.6.6 Android: 5.0.2

  var message = [
    $window.ndef.textRecord(textData),
  ];
  $window.nfc.write(message, ...)

produces the following error:

"Attempt to invoke virtual method 'android.os.Parcelable android.content.Intent.getParcelableExtra(java.lang.String)' on a null object reference"

This error occurs when there hasn't been any tag attached to the device since the app start - this error changes to 'null' once a tag is attached to the device

don commented 8 years ago

On Android the write method must be called from within an NDEF Event Handler. It fails if there's no tag present.