Этот код работает в 4.3 и 4.2, но не получает песни с 4.4.4 устройства Motorolla Moto G.Android: Песни не отображаются в 4.4.4
Вот мой код.
final String MEDIA_PATH = Environment.getExternalStorageDirectory() .getPath() + "/"; private ArrayList> songsList = new ArrayList>(); общественные пустоты BindAllSongs() {
/* Создание пользовательских вытяжке */
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();
}
}*
этот код не получает любую песню от Motorola G 4.4.4.How может решить эту проблему?