Merge "Add null check to avoid crash when incoming beam of contact"
diff --git a/src/com/android/apps/tag/TagViewer.java b/src/com/android/apps/tag/TagViewer.java
index 682dba5..70c758e 100644
--- a/src/com/android/apps/tag/TagViewer.java
+++ b/src/com/android/apps/tag/TagViewer.java
@@ -73,6 +73,15 @@
         }
     }
 
+    private void addView(LayoutInflater inflater, LinearLayout content, View v) {
+        if (v == null) {
+            TextView empty = (TextView) inflater.inflate(R.layout.tag_text, content, false);
+            empty.setText(R.string.tag_empty);
+            v = empty;
+        }
+        content.addView(v);
+    }
+
     void buildTagViews(NdefMessage msg) {
         LayoutInflater inflater = LayoutInflater.from(this);
         LinearLayout content = mTagContent;
@@ -82,9 +91,7 @@
 
         // Build views for all of the sub records
         if (msg == null) {
-            TextView empty = (TextView) inflater.inflate(R.layout.tag_text, content, false);
-            empty.setText(R.string.tag_empty);
-            content.addView(empty);
+            addView(inflater, content, null);
         } else {
             // Parse the first message in the list
             //TODO figure out what to do when/if we support multiple messages per tag
@@ -93,13 +100,11 @@
             List<ParsedNdefRecord> records = parsedMsg.getRecords();
             final int size = records.size();
             if (size == 0) {
-                TextView empty = (TextView) inflater.inflate(R.layout.tag_text, content, false);
-                empty.setText(R.string.tag_empty);
-                content.addView(empty);
+                addView(inflater, content, null);
             } else {
                 for (int i = 0; i < size; i++) {
                     ParsedNdefRecord record = records.get(i);
-                    content.addView(record.getView(this, inflater, content, i));
+                    addView(inflater, content, record.getView(this, inflater, content, i));
                     inflater.inflate(R.layout.tag_divider, content, true);
                 }
             }
diff --git a/src/com/android/apps/tag/record/VCardRecord.java b/src/com/android/apps/tag/record/VCardRecord.java
index 7d2099f..01328c0 100644
--- a/src/com/android/apps/tag/record/VCardRecord.java
+++ b/src/com/android/apps/tag/record/VCardRecord.java
@@ -84,6 +84,9 @@
     public View getView(Activity activity, LayoutInflater inflater, ViewGroup parent, int offset) {
 
         Uri uri = activity.getIntent().getData();
+        if (uri == null) {
+            return null;
+        }
         uri = Uri.withAppendedPath(uri, Integer.toString(offset));
         uri = Uri.withAppendedPath(uri, "mime");