2013-09-11 61 views

回答

1

您可以使用get铃声列表RingtoneManager

public void listRingtones() { 
    RingtoneManager manager = new RingtoneManager(this); 
    manager.setType(RingtoneManager.TYPE_RINGTONE); 
    Cursor cursor = manager.getCursor(); 
    while (cursor.moveToNext()) { 
    String title = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX); 
    String uri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX); 
    // Do something with the title and the URI of ringtone 
    } 
} 
+2

为了记录,您需要为此使用''。 –

+0

@Yichiichi Araki如何获取手动添加铃声的铃声URI,因为使用此代码我只能获得系统铃声列表?请帮忙 –

5

我已upvote佑一的答案,但它并没有完全为我工作。对于每个铃声,我得到了相同的URI(不同的标题思想)。以下代码适用于我 -

public void listRingtones() { 
    RingtoneManager manager = new RingtoneManager(this); 
    manager.setType(RingtoneManager.TYPE_RINGTONE); 
    Cursor cursor = manager.getCursor(); 
    while (cursor.moveToNext()) { 
    String title = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX); 
    Uri ringtoneURI = manager.getRingtoneUri(cursor.getPosition()); 
    // Do something with the title and the URI of ringtone 
    } 
} 

您可以在playstore上看到正在运行的应用程序。

+0

只有这段代码才能让我获得包括名字在内的所有铃声。谢谢! –

+0

@Aniket Thakur如何获取手动添加铃声的铃声URI,因为使用此代码我只能获得系统铃声列表?请帮忙 –

+0

如何取名 –

相关问题