gpt4 book ai didi

android - getcontentresolver() 在服务中返回 null

转载 作者:太空宇宙 更新时间:2023-11-03 11:20:46 24 4
gpt4 key购买 nike

在下面的代码中,getcontentresolver() 为空,但在服务的onCreate() 中起作用,但在服务中的函数中不起作用。为什么?请帮助我..谢谢

    final Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
final String[] cursor_cols = { MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA };

final String where = MediaStore.Audio.Media.IS_MUSIC + "=1";

cursor = getContentResolver()
.query(uri, cursor_cols, where, null, null);

最佳答案

确保您与设备的 USB 连接处于 PC 模式,而不是 USB 大容量存储

如果在大容量存储中,则返回null

关于android - getcontentresolver() 在服务中返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8802710/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com