Issue 521, avoid an NPE
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 22 Aug 2010 21:58:11 +0000 (21:58 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 22 Aug 2010 21:58:11 +0000 (21:58 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1552 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/src/com/google/zxing/client/android/share/ShareActivity.java

index a116f74..696b389 100755 (executable)
@@ -151,6 +151,10 @@ public final class ShareActivity extends Activity {
   }
 
   private void showTextAsBarcode(String text) {
   }
 
   private void showTextAsBarcode(String text) {
+    Log.i(TAG, "Showing text as barcode: " + text);    
+    if (text == null) {
+      return; // Show error?
+    }
     Intent intent = new Intent(Intents.Encode.ACTION);
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
     intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
     Intent intent = new Intent(Intents.Encode.ACTION);
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
     intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
@@ -167,6 +171,9 @@ public final class ShareActivity extends Activity {
    */
   private void showContactAsBarcode(Uri contactUri) {
     Log.i(TAG, "Showing contact URI as barcode: " + contactUri);
    */
   private void showContactAsBarcode(Uri contactUri) {
     Log.i(TAG, "Showing contact URI as barcode: " + contactUri);
+    if (contactUri == null) {
+      return; // Show error?
+    }
     ContentResolver resolver = getContentResolver();
     Cursor contactCursor = resolver.query(contactUri, null, null, null, null);
     Bundle bundle = new Bundle();
     ContentResolver resolver = getContentResolver();
     Cursor contactCursor = resolver.query(contactUri, null, null, null, null);
     Bundle bundle = new Bundle();