在OS上面的4.6中播放器创建期间发生ControlledAccessException!

时间:2010-01-19 10:27:56

标签: blackberry

PLease建议如何克服此异常,我的代码如下:

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 );

谢谢和问候 Mintu

1 个答案:

答案 0 :(得分:0)

除了ApplicationPermissions.PERMISSION_MEDIA(您的代码中已有),我们发现有时需要ApplicationPermissions.PERMISSION_CHANGE_DEVICE_SETTINGS权限才能播放音频。我不确定为什么,但试一试,看看它是否有帮助。