2

我收到了来自运行 Android 2.2 的几个不同用户的以下错误报告。我无法在本地复制它。

java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider uri content://settings/system from pid=15121, uid=10063 requires android.permission.WRITE_SETTINGS
    at android.os.Parcel.readException(Parcel.java:1247)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
    at android.content.ContentProviderProxy.insert(ContentProviderNative.java:408)
    at android.content.ContentResolver.insert(ContentResolver.java:587)
    at android.provider.Settings$NameValueTable.putString(Settings.java:556)
    at android.provider.Settings$System.putString(Settings.java:753)
    at android.provider.Settings$System.putInt(Settings.java:836)
    at android.widget.MediaController.dolbySwitch(MediaController.java:835)
    at android.widget.MediaController.access$1100(MediaController.java:89)
    at android.widget.MediaController$6.onClick(MediaController.java:763)
    at android.view.View.performClick(View.java:2408)
    at android.view.View$PerformClick.run(View.java:8816)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4669)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
    at dalvik.system.NativeStart.main(Native Method)

我的代码不应该试图更改任何设置——我只是用 MediaController 创建一个简单的 VideoView 并让它加载一个 URI。

这个错误似乎非常罕见,所以这不是一个大问题,但我不明白是什么原因造成的。

编辑:根据要求,这是 VideoView 和 MediaController 的代码:

  private void videoViewInit() 
  {
      videoView = (VideoView)findViewById(R.id.videoView);
      MediaController mediaController = new MediaController(this);
      mediaController.setAnchorView(videoView);
      mediaController.setMediaPlayer(videoView);
      videoView.setMediaController(mediaController);
      videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
            @Override
            public boolean onError(MediaPlayer mp, int errorType, int extra) {
                    return false;
            }});
      videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){
            @Override
            public void onPrepared(MediaPlayer mp) {
                  videoView.requestFocus();
            }});
      videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
            }});
  }

  protected void videoViewDisable()  {
      videoView.stopPlayback();
  }

  private void videoViewLoad(Uri uri) {
      if( uri == null || uri.toString().equals("") )
          return;

      if( videoView == null )
              videoViewInit();

      videoView.setVideoURI( uri );
      videoView.start();
  }
4

1 回答 1

3

将此权限添加到清单文件

 < uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission> 
于 2011-08-23T09:21:20.837 回答