android RingtoneManager 铃声管理器

 

获取默认铃声Uri/

Uri String

 
Uri sound = RingtoneManager.getDefaultUri(type);
(type = RingtoneManager.TYPE_RINGTONE or RingtoneManager.TYPE_NOTIFICATION or RingtoneManager.TYPE_ALARM
以下同)

获取铃声Uri/

Uri String

String getRingtoneUriPath(int type,int pos){
RingtoneManager manager = new RingtoneManager(mContext);
manager.setType(type);

//workaround to create mCusor inside manager, or raise a segamentation fault while invoking getRingtoneUri, below methods same too

Cursor cursor = manager.getCursor();

Uri uri = manager.getRingtoneUri(pos);
return uri==null? null:uri.toString();
}

获取铃声标题 List<String> getRingtoneTitleList(int type){ 

List<String> resArr = new ArrayList<String>();
RingtoneManager manager = new RingtoneManager(mContext);
manager.setType(type);
Cursor cursor = manager.getCursor();
if(cursor.moveToFirst()){
do{
resArr.add(cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX));
}while(cursor.moveToNext());
}
return resArr;
}

获取指定类型的

指定条目铃声操作类

Ringtone getRingtone(int type,int pos){ 

RingtoneManager manager = new RingtoneManager(mContext);
manager.setType(type);
return manager.getRingtone(pos);
}

获取指定类型所有

铃声操作列表

List<Ringtone> getRingtoneList(int type){
List<Ringtone> resArr = new ArrayList<Ringtone>();
RingtoneManager manager = new RingtoneManager(mContext);
manager.setType(type);
Cursor cursor = manager.getCursor();
int count = cursor.getCount();
for(int i = 0 ; i < count ; i ++){
resArr.add(manager.getRingtone(i));
}
return resArr;
}

posted @ 2018-09-07 08:37  Reboost  阅读(3954)  评论(0编辑  收藏  举报