安卓:歌曲都没有显示在4.4.4 [英] Android: Songs are not showing in 4.4.4
问题描述
这code是工作在4.3和4.2,但是它没有得到歌曲4.4.4 Motorolla摩托摹设备。
This code is working in 4.3 and 4.2 but it is not getting songs from 4.4.4 Motorolla Moto G device.
下面是我的code。
最后弦乐MEDIA_PATH = Environment.getExternalStorageDirectory()
.getPath()+/;
私人的ArrayList> songsList =新的ArrayList>();
公共无效BindAllSongs(){
/ * 的制作自定义绘制* /
final String MEDIA_PATH = Environment.getExternalStorageDirectory()
.getPath() + "/";
private ArrayList> songsList = new ArrayList>();
public void BindAllSongs() {
/* Making custom drawable */
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
final String[] projection = new String[] {
MediaStore.Audio.Media.DISPLAY_NAME,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.DURATION};
final String sortOrder = MediaStore.Audio.AudioColumns.TITLE
+ " COLLATE LOCALIZED ASC";
try {
// the uri of the table that we want to query
Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
// query the db
cursor = context.getContentResolver().query(uri,
projection, selection, null, sortOrder);
if (cursor != null) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
String songTitle = cursor.getString(0);
String songArtist = cursor.getString(1);
String songData = cursor.getString(2);
String duration = cursor.getString(3);
HashMap<String, String> songMap = new HashMap<String, String>();
songMap.put("songTitle", songTitle);
songMap.put("songDuration", duration);
songMap.put("songAuthor", songArtist);
songMap.put("songPath", songData);
songsList.add(songMap);
cursor.moveToNext();
}
}
} catch (Exception ex) {
} finally {
if(cursor == null)
{
AlertDialog("No Song Found from your Device");
}
else if (cursor !=null)
{
AlertDialog(String.valueOf(cursor.getCount()) + " Song Found");
}
if (cursor != null) {
cursor.close();
}
}*
这code没有得到摩托罗拉摹4.4.4.How任何一首歌曲可以解决这个问题?
this code is not getting any song from Motorola G 4.4.4.How can solve this problem?
推荐答案
我已经在它加入的查询,而不是比较扩展解决了这个问题。
I have solved this problem by adding query in it instead of comparing extension.
这篇关于安卓:歌曲都没有显示在4.4.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!