java.lang.RuntimeException:无法启动活动ComponentInfo {com.MediaPlayer / com.MediaPlayer.MainActivity}: java.lang.SecurityException:权限拒绝:阅读 com.android.providers.media.MediaProvider uri内容://媒体/ pid = 1875,uid = 10141所需的外部/音频/媒体 android.permission.READ_EXTERNAL_STORAGE或grantUriPermission(),位于 android.app.ActivityThread.performLaunchActivity(ActivityThread.java :706),位于android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2767)在android.app.ActivityThread.-wrap12 (ActivityThread.java)在android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1514)位于android.os.Handler.dispatchMessage (Handler.java:102)在android.os.Looper.loop(Looper.java:163)在 android.app.ActivityThread.main(ActivityThread.java:6205)在 java.lang.reflect.Method.invoke(本机方法)位于 com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:904)在com.android.internal.os.ZygoteInit.main (ZygoteInit.java:794)原因:java.lang.SecurityException:拒绝 权限:阅读com.android.providers.media.MediaProvider uri 内容://媒体/外部/音频/媒体来自pid = 1875,uid = 10141需要android.permission.READ_EXTERNAL_STORAGE,或者 grantUriPermission(),位于android.os.Parcel.readException (Parcel.java:1684)在 android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:183)在 android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:135)在android.content.ContentProviderProxy.query (ContentProviderNative.java:421)在 android.content.ContentResolver.query(ContentResolver.javaambat34)在 android.content.ContentResolver.query(ContentResolver.java:475)在 com.MediaPlayer.MainActivity.getSongList(MainActivity.java:21)位于 com.MediaPlayer.MainActivity.onCreate(MainActivity.java:51)位于 android.app.Activity.performCreate(Activity.java:6864)在 android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1119)在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java :659)...还有9个
答案 0 :(得分:1)
您只需要授予访问外部存储的权限即可。
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE">
答案 1 :(得分:1)
寻找您的AndroidManifeest.xml并添加<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE">