5 Replies Latest reply on Mar 21, 2014 1:54 PM by Sarin Regmi

    scanner beep

    Roger Whitehead

      We noticed recently that the Concierge doesn't beep when the scanner is triggered.  I don't think it ever did, but I'm not sure.  I've checked the volume settings and they seem to be fine.  I've implemented the code below to programmatically beep on a scan, but it works only very occasionally.


      public boolean onBarcodeScan(BarcodeScanEvent event) {
         String scanData = event.getCharacters();
         //beep for the scanner
         ToneGenerator generator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
      //...code to handle barcode...
         return true;


        • Re: scanner beep
          Roger Whitehead

          I am seeing this in the log:


          01-08 05:27:57.968: I/PhoneWindow(4526): Creating a new instance of the static AsyncPlayer

          01-08 05:27:57.968: I/PhoneWindow(4526): Starting tone playback.

          01-08 05:27:57.976: D/MediaPlayer(4526): Couldn't open file on client side, trying server side

          01-08 05:27:57.984: E/MediaPlayer(4526): Unable to to create media player

          01-08 05:27:57.984: W/PhoneWindow(4526): error loading sound for content://settings/system/notification_sound

          01-08 05:27:57.984: W/PhoneWindow(4526): java.io.IOException: setDataSource failed.: status=0x80000000

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.MediaPlayer._setDataSource(Native Method)

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1012)

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1000)

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:953)

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:900)

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.AsyncPlayer.startSound(AsyncPlayer.java:62)

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.AsyncPlayer.access$200(AsyncPlayer.java:33)

          01-08 05:27:57.984: W/PhoneWindow(4526):     at android.media.AsyncPlayer$Thread.run(AsyncPlayer.java:97)

            • Re: scanner beep
              Roger Whitehead

              I'm trying a different approach to get sound to play, and I'm still encountering inconsistency.  The approach below seems to work once and then fail until the device is rebooted, which makes me think that resources are not released correctly, but setting breakpoints in a debugger shows that the onCompletion() executes without an exception.  In the code below, the player variable is a class member.


                 try {
                 AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                 audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, audioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION), 0);
                 player = MediaPlayer.create(mActivity, R.raw.fallbackring);
                 player.setVolume((float)0.5, (float)0.5);
                 player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {


                 public void onCompletion(MediaPlayer mp) {
                 } catch (Exception e) {
                 if (player != null)


              In the cases where the sound doesn't play, the LogCat looks like this:


              01-09 02:41:14.703: I/PhoneWindow(853): Creating a new instance of the static AsyncPlayer

              01-09 02:41:14.710: I/PhoneWindow(853): Starting tone playback.

              01-09 02:41:14.718: D/MediaPlayer(853): Couldn't open file on client side, trying server side

              01-09 02:41:14.718: E/MediaPlayer(853): Unable to to create media player

              01-09 02:41:14.734: W/PhoneWindow(853): error loading sound for content://settings/system/notification_sound

              01-09 02:41:14.734: W/PhoneWindow(853): java.io.IOException: setDataSource failed.: status=0x80000000

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.MediaPlayer._setDataSource(Native Method)

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1012)

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1000)

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:953)

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.MediaPlayer.setDataSource(MediaPlayer.java:900)

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.AsyncPlayer.startSound(AsyncPlayer.java:62)

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.AsyncPlayer.access$200(AsyncPlayer.java:33)

              01-09 02:41:14.734: W/PhoneWindow(853):     at android.media.AsyncPlayer$Thread.run(AsyncPlayer.java:97)

              01-09 02:41:15.117: D/PhoneWindow(853): Barcode scan detected (000000210010)

              01-09 02:41:15.117: W/PhoneWindow(853): Magic barcode  not found in system properties; using default magic barcode

              01-09 02:41:15.125: D/PhoneWindow(853): Letting window callbacks dispatch event

              01-09 02:41:16.718: I/PhoneWindow(853): Tone released after timeout

              01-09 02:41:16.718: W/PhoneWindow(853): STOP command without a player


              The sound used is fallbackring,ogg copied from android-sdk-windows\platforms\android-19\data\res\raw to the project's res/raw.

                • Re: scanner beep

                  Hi Roger.  The log messages you included above are a result of having your "Default notification" set to "Silent".  Basically, "Silent" is a fancy way of saying "no sound file", hence the log messages about not being able to load the sound.


                  Navigate to Settings -> Sound -> Default notification, and change this to the sound that you want played on barcode scan.


                  Your system being set to "Silent" is an unfortunate consequence of you having been given early access to a pre-release platform (pre prior to the official release.  Factory builds of come with a default notification setting of "Pixie Dust".


                  Apologies for the inconvenience.

                    • This reply has been hidden. This can happen if the message has been hidden by a moderator, or has been reported as abusive.
              • Re: scanner beep

                Sound should be playing whenever a barcode scan intercept is made. I was able to play it just now on my device and it seemed to work just fine . Whatever errors you are seeing as on your last reply are coming from the android platform and not from the code you added. I am not sure what platform you are running on but it seems like the MediaPlayer is not being able to set the source.