Fixed handling of new Android Intent result
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 10 Mar 2008 21:23:58 +0000 (21:23 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 10 Mar 2008 21:23:58 +0000 (21:23 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@261 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/src/com/google/zxing/client/android/AndroidIntentParsedResult.java
android/src/com/google/zxing/client/android/BarcodeReaderCaptureActivity.java
android/src/com/google/zxing/client/android/ResultHandler.java

index 40f4fec..471410c 100644 (file)
@@ -42,6 +42,8 @@ public final class AndroidIntentParsedResult extends ParsedReaderResult {
       return new AndroidIntentParsedResult(Intent.getIntent(rawText));
     } catch (URISyntaxException urise) {
       return null;
+    } catch (IllegalArgumentException iae) {
+      return null;
     }
   }
 
index f8d1a97..52c5d68 100644 (file)
@@ -18,6 +18,7 @@ package com.google.zxing.client.android;
 
 import android.app.Activity;
 import android.content.Context;
+import android.content.Intent;
 import android.graphics.PixelFormat;
 import android.os.Bundle;
 import android.os.Handler;
@@ -179,9 +180,14 @@ public final class BarcodeReaderCaptureActivity extends Activity {
     String rawText = rawResult.getText();
     ParsedReaderResult readerResult = ParsedReaderResult.parseReaderResult(rawText);
     if (readerResult.getType().equals(ParsedReaderResultType.TEXT)) {
-      ParsedReaderResult androidResult = AndroidIntentParsedResult.parse(rawText);
+      AndroidIntentParsedResult androidResult = AndroidIntentParsedResult.parse(rawText);
       if (androidResult != null) {
-        readerResult = androidResult;
+        Intent intent = androidResult.getIntent();
+        if (!Intent.VIEW_ACTION.equals(intent.getAction())) {
+          // For now, don't take anything that just parses as a View action. A lot
+          // of things are accepted as a View action by default.
+          readerResult = androidResult;          
+        }
       }
     }
     return readerResult;
index 9d8f1b7..0950af1 100755 (executable)
@@ -119,6 +119,8 @@ final class ResultHandler extends Handler {
         } catch (URISyntaxException e) {
           return;
         }
+      } else if (type.equals(ParsedReaderResultType.ANDROID_INTENT)) {
+        intent = ((AndroidIntentParsedResult) result).getIntent();
       }
       if (intent != null) {
         captureActivity.startActivity(intent);