tags:

views:

24

answers:

1

Hi viewers!

PLease suggest how to overcome from this exception, my code is given below:

String TestFile = "file:///" + RTTToneImpl.getEmergencyTone();
       Player player;
       try
       {
           player = Manager.createPlayer(TestFile);
       }
       catch(ControlledAccessException e)
       {
           Dialog errorDialog = new Dialog(0, "Please use the BlackBerry Options application to allow Media Access permission for Ring Trump Tones.", 0, Bitmap.getPredefinedBitmap(2), 0L);
           errorDialog.doModal();
           System.exit(0);
       }
       catch(IOException e)
       {
           Dialog errorDialog = new Dialog(0, "Caught IOException type when checking media permission:- " + e.getMessage(), 0, Bitmap.getPredefinedBitmap(2), 0L);
           errorDialog.doModal();
           System.exit(0);
       }
       catch(Exception e)
       {
           Dialog errorDialog = new Dialog(0, "Unexpected exception type when checking media permission:- " + e.getMessage(), 0, Bitmap.getPredefinedBitmap(2), 0L);
           errorDialog.doModal();
           System.exit(0);
       }
ApplicationPermissions permRequest = ApplicationPermissionsManager.getInstance().getApplicationPermissions();
       if( permRequest.getPermission( ApplicationPermissions.PERMISSION_MEDIA ) == ApplicationPermissions.VALUE_ALLOW )
       {
                 return ;
       }
       permRequest = new ApplicationPermissions();
       permRequest.addPermission( ApplicationPermissions.PERMISSION_MEDIA );
       permRequest.addPermission( ApplicationPermissions.PERMISSION_FILE_API );

       ApplicationPermissionsManager.getInstance().invokePermissionsRequest( permRequest );

Thanks and Regards Mintu

A: 

In addition to ApplicationPermissions.PERMISSION_MEDIA (which you have in your code), we found that we sometimes needed the ApplicationPermissions.PERMISSION_CHANGE_DEVICE_SETTINGS permission in order to play audio. I'm not sure why, but give that a try and see if it helps.

Marc Novakowski