Workaround for NPE on some Nokias from webblaz...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 23 Apr 2009 07:01:00 +0000 (07:01 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 23 Apr 2009 07:01:00 +0000 (07:01 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@916 59b500cc-1b3d-0410-9834-0bbf25fbcc57

javame/src/com/google/zxing/client/j2me/ZXingMIDlet.java

index 8335a53..f1bb635 100644 (file)
@@ -138,13 +138,21 @@ public final class ZXingMIDlet extends MIDlet {
         player = Manager.createPlayer("capture://image");\r
       } catch (MediaException me) {\r
         // if this fails, just continue with capture://video\r
+      } catch (NullPointerException npe) { // Thanks webblaz... for this improvement:\r
+        // The Nokia 2630 throws this if image/video capture is not supported\r
+        // We should still try to continue\r
       } catch (Error e) {\r
         // Ugly, but, it seems the Nokia N70 throws "java.lang.Error: 136" here\r
         // We should still try to continue\r
       }\r
     }\r
     if (player == null) {\r
-      player = Manager.createPlayer("capture://video");\r
+      try {\r
+        player = Manager.createPlayer("capture://video");\r
+      } catch (NullPointerException npe) {\r
+        // The Nokia 2630 throws this if image/video capture is not supported\r
+        throw new MediaException("Image/video capture not supported on this phone");\r
+      }\r
     }\r
     return player;\r
   }\r