zoukankan      html  css  js  c++  java
  • Android-Android7.0-java.lang.SecurityException: MODE_WORLD_READABLE no longer supported

    某个AndroidProject项目在Android5.0系统运行是OK的,在Android7.0以上版本运行,报以下错误❌

    2019-01-02 15:33:39.996 17067-17067/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: liudeli.music2:remote, PID: 17067
    java.lang.RuntimeException: Unable to create service liudeli.music2.service.MediaPlaybackService: java.lang.SecurityException: MODE_WORLD_READABLE no longer supported
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3226)
    at android.app.ActivityThread.-wrap5(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1586)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6186)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
    Caused by: java.lang.SecurityException: MODE_WORLD_READABLE no longer supported
    at android.app.ContextImpl.checkMode(ContextImpl.java:2134)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:354)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:349)
    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:164)
    at liudeli.music2.service.MediaPlaybackService.onCreate(MediaPlaybackService.java:345)


    解决方法:

    // mPreferences = getSharedPreferences("Music", MODE_WORLD_READABLE | MODE_WORLD_WRITEABLE);
    mPreferences = getSharedPreferences("music", MODE_PRIVATE);

    把 MODE_WORLD_READABLE 更换成 MODE_PRIVATE 即可,因为MODE_WORLD_READABLE 模式已经被废弃

  • 相关阅读:
    MSMQ 跨服务器读写队列的“消息队列系统的访问被拒绝”的解决方案
    WCF中的ServiceHost初始化两种方式
    正则表达式规则
    常用正则表达式
    Visual Studio 2017使用Asp.Net Core构建Angular4应用程序
    斑马打印机ZT410中文打印
    CNPM 安装 for angularjs
    MAC OS X&Vmware
    HBase
    SQL 和 NoSQL 比较
  • 原文地址:https://www.cnblogs.com/android-deli/p/10208921.html
Copyright © 2011-2022 走看看