Music Player asking for Write External Storage Permission?

风流意气都作罢 提交于 2019-12-05 10:52:08
user2481360

From the MediaProvider code, which handles "/media/external/audio/albumart"

Inside openFile(Uri uri, String mode)

try {
    pfd = openFileAndEnforcePathPermissionsHelper(newUri, mode);
} catch (FileNotFoundException ex) {
    // That didn't work, now try to get it from the specific file
    pfd = getThumb(database, db, audiopath, albumid, null);
}

So if file not found, it calls getThumb

getThumb calls makeThumbInternal

Then under certain conditions, it calls

writeAlbumArt(need_to_recompress, out, compressed, bm);

In the latest version, writeAlbumArt calls

final long identity = Binder.clearCallingIdentity();

before writing, which is supposed to solve the problem. But the fix was committed on Aug 27, 2015, so only Marshmallow has a chance to get the fix.

It is needed because MediaStore requires it, there is no READ-ONLY; MediaStore is accessing external files on your behave, so it is you doing the reading.

Declare the permission in manifest file as below:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!