Created
April 10, 2015 08:23
-
-
Save anonymous/abc90a6339cd9b6c3342 to your computer and use it in GitHub Desktop.
EMDK race condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/src/main/java/com/symbol/barcodesample1/MainActivity.java b/app/src/main/java/com/symbol/barcodesample1/MainActivity.java | |
index bdfaa30..1409d63 100644 | |
--- a/app/src/main/java/com/symbol/barcodesample1/MainActivity.java | |
+++ b/app/src/main/java/com/symbol/barcodesample1/MainActivity.java | |
@@ -516,13 +516,21 @@ public class MainActivity extends Activity implements EMDKListener, DataListener | |
scanner.addDataListener(this); | |
scanner.addStatusListener(this); | |
+ new AsyncEnable().execute(scanner); | |
+ } | |
+ } | |
+ } | |
+ | |
+ private static final class AsyncEnable extends AsyncTask<Scanner, Void, Void> { | |
+ @Override | |
+ protected Void doInBackground(final Scanner... params) { | |
try { | |
- scanner.enable(); | |
+ params[0].enable(); | |
} catch (ScannerException e) { | |
- | |
- textViewStatus.setText("Status: " + e.getMessage()); | |
- } | |
+ e.printStackTrace(); | |
+ throw new RuntimeException(e); | |
} | |
+ return null; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (scanner != null) { | |
scanner.addDataListener(this); | |
scanner.addStatusListener(this); | |
new AsyncEnable().execute(scanner); | |
} | |
} | |
} | |
private static final class AsyncEnable extends AsyncTask<Scanner, Void, Void> { | |
@Override | |
protected Void doInBackground(final Scanner... params) { | |
try { | |
params[0].enable(); | |
} catch (ScannerException e) { | |
e.printStackTrace(); | |
throw new RuntimeException(e); | |
} | |
return null; | |
} | |
} | |
private void deInitScanner() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment