Fix NPE when receiving a NDEF message of 0 length.
Jason parks [Wed, 3 Nov 2010 03:50:09 +0000 (22:50 -0500)]
Change-Id: I44661f453f7819b7847bb892f868cb05bdd66aaa

src/com/android/apps/tag/TagViewer.java

index 92ff03b..7b7f5ca 100644 (file)
@@ -179,7 +179,7 @@ public class TagViewer extends Activity implements OnClickListener {
             // that time we read it from the database and view it.
             Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
             NdefMessage[] msgs;
-            if (rawMsgs != null) {
+            if (rawMsgs != null && rawMsgs.length > 0) {
                 // stupid java, need to cast one-by-one
                 msgs = new NdefMessage[rawMsgs.length];
                 for (int i=0; i<rawMsgs.length; i++) {