问题描述
- Android为什么设置铃声后为静音
-
public void change(int position){
Mp3Info mp3Info = getMusic.getMp3Infos(MainActivity.this).get(position);
File sdfile = new File(mp3Info.getUrl());
// Toast.makeText(MainActivity.this, mp3Info.getUrl(), Toast.LENGTH_LONG).show();
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DATA, sdfile.getAbsolutePath());
values.put(MediaStore.MediaColumns.TITLE, sdfile.getName());
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
values.put(MediaStore.Audio.Media.IS_RINGTONE, false);
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true);
values.put(MediaStore.Audio.Media.IS_ALARM, false);
values.put(MediaStore.Audio.Media.IS_MUSIC, false);Uri uri = MediaStore.Audio.Media.getContentUriForPath(sdfile .getAbsolutePath()); Uri newUri = this.getContentResolver().insert(uri, values); RingtoneManager.setActualDefaultRingtoneUri(MainActivity.this, RingtoneManager.TYPE_NOTIFICATION, newUri); Toast.makeText(getApplicationContext(), mp3Info.getArtist()+"", Toast.LENGTH_SHORT) .show(); }
最后的Toast可以获取歌曲歌手,说明得到了歌曲啊,为什么设置后就变为静音了
时间: 2024-11-01 10:59:36