Android の組み込みの着信音ファイルから特定のオーディオ ファイルを再生できるかどうかを知る必要があります。たとえば、Tone_23 が Android の着信音リストにあるとします。ボタンをクリックすると、この特定のトーンを再生する必要があります。Google で検索したところ、RingtonePicker のアクティビティを呼び出す/表示する方法のガイダンスが得られました (着信音リスト全体が表示されます)。これが可能な場合は、親切にあなたの考えを共有してください。前もって感謝します。
2100 次
2 に答える
2
次のようなことを試すことができます:
/**
* Play ring tone.
*
* @param ringToneTitle the ring tone title
*/
void playRingTone(String ringToneTitle) {
RingtoneManager ringtoneManager = new RingtoneManager(
getApplicationContext());
ringtoneManager.setType(RingtoneManager.TYPE_RINGTONE);
int length = ringtoneManager.getCursor().getCount();
for (int i = 0; i < length; i++) {
Ringtone mRingtone = ringtoneManager.getRingtone(i);
if (mRingtone != null) {
Log.d("ringtoneTitle ", mRingtone.getTitle(getApplicationContext()));
if(ringToneTitle.equalsIgnoreCase(mRingtone
.getTitle(getApplicationContext())) {
mRingtone.play();
}
}
}
}
お役に立てれば。
追加:このクラスRingtoneManagerも見てください
RingtoneManager provides access to ringtones, notification, and other types of sounds. It manages querying the different media providers and combines the results into a single cursor. It also provides a Ringtone for each ringtone. We generically call these sounds ringtones, however the TYPE_RINGTONE refers to the type of sounds that are suitable for the phone ringer.
于 2012-09-25T18:21:11.177 に答える
0
たとえば、システムで自動的に設定されている着信音のみを再生できると思います。
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
常に特定のトーン/ファイルを再生したい場合は、それをアセットに追加してそこから再生する必要があります。
于 2012-09-25T18:07:33.890 に答える