Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android 在音樂播放器中設置一首歌曲為來電鈴聲,設置不起作用

android 在音樂播放器中設置一首歌曲為來電鈴聲,設置不起作用

編輯:關於Android編程

AudioProfile,情景模式,多卡設置鈴聲
系統開啟Multi_ringtone_support。進入菜單--音樂--歌曲列表--長按一首歌曲選擇設為手機鈴聲,提示已成功設置,但是進入設置中情景模式查看,仍然是默認鈴聲。打電話後鈴聲還為默認鈴聲。
修改:
AudioProfileService.java
mRingtoneObserver = new ContentObserver(new Handler())函數裡面的
case GENERAL:
case OUTDOOR:
if (mExt.shouldSyncGeneralRingtoneToOutdoor()) {
// If ringtone has been changed and the active profile is general
// or outdoor profile, synchronize the current system ringtone
// to both profiles.
if (isPassiveChange && (!mResetFlag)) {
String generalKey = mPredefinedKeys.get(Scenario.GENERAL.ordinal());
String outdoorKey = mPredefinedKeys.get(Scenario.OUTDOOR.ordinal());
getProfileState(generalKey, mSimId).mRingerStream = systemUri;
getProfileState(outdoorKey, mSimId).mRingerStream = systemUri;
persistRingtoneUriToDatabase(generalKey, AudioProfileManager.TYPE_RINGTONE, mSimId, systemUri);
persistRingtoneUriToDatabase(outdoorKey, AudioProfileManager.TYPE_RINGTONE, mSimId, systemUri);
Log.d(TAG, "Ringtone changed by other app in non-silent "
+ "profile, synchronize to active profile: new uri = " + systemUri);
} else {
Log.d(TAG, "Ringtone changed by itself, do nothing!");
}
break;
}
改為如下的樣子
case GENERAL:
case OUTDOOR:
if (mExt.shouldSyncGeneralRingtoneToOutdoor()) {
// If ringtone has been changed and the active profile is general
// or outdoor profile, synchronize the current system ringtone
// to both profiles.
if (isPassiveChange && (!mResetFlag)) {
//M: for setringtoneformprofile or from 3rd app
if (FeatureOption.MTK_MULTISIM_RINGTONE_SUPPORT) {
// add to get selected SIM id
List simList = SIMInfo.getInsertedSIMList(mContext);
int simNum = simList.size();
Log.d(TAG, "simList.size() == " + simNum);
long simId = -1;
for (int i = 0; i < simNum; i++) {
simId = simList.get(i).mSimId;

String generalKey = mPredefinedKeys.get(Scenario.GENERAL.ordinal());
String outdoorKey = mPredefinedKeys.get(Scenario.OUTDOOR.ordinal());
getProfileState(generalKey, simId).mRingerStream = systemUri;
getProfileState(outdoorKey, simId).mRingerStream = systemUri;
persistRingtoneUriToDatabase(generalKey, AudioProfileManager.TYPE_RINGTONE, simId, systemUri);
persistRingtoneUriToDatabase(outdoorKey, AudioProfileManager.TYPE_RINGTONE, simId, systemUri);
Log.d(TAG, "Ringtone changed by other app in non-silent "
+ "profile, synchronize to active profile: new uri = " + systemUri);
Log.d(TAG,"mRingtoneObserver simId " + simId);
}
}else {
String generalKey = mPredefinedKeys.get(Scenario.GENERAL.ordinal());
String outdoorKey = mPredefinedKeys.get(Scenario.OUTDOOR.ordinal());
getProfileState(generalKey, mSimId).mRingerStream = systemUri;
getProfileState(outdoorKey, mSimId).mRingerStream = systemUri;
persistRingtoneUriToDatabase(generalKey, AudioProfileManager.TYPE_RINGTONE, mSimId, systemUri);
persistRingtoneUriToDatabase(outdoorKey, AudioProfileManager.TYPE_RINGTONE, mSimId, systemUri);
Log.d(TAG, "Ringtone changed by other app in non-silent "
+ "profile, synchronize to active profile: new uri = " + systemUri);
}

} else {
Log.d(TAG, "Ringtone changed by itself, do nothing!");
}
break;
}
同樣的,對於custom case 也要處理
Case CUSTOM:
if (isPassiveChange && (!mResetFlag )){
activeState.mRingerStream = systemUri;
persistRingtoneUriToDatabase(mActiveProfileKey,AudioProfileManager.TYPE_RINGTONE,mSimId,systemUri);
Log.d(…);
} else {
Log.d(…);
}
break;
改為,
Case CUSTOM:
if (isPassiveChange && (!mResetFlag )){
if (FeatureOption.MTK_MULTISIM_RINGTONE_SUPPORT){
// add to get selected SIM id
List simList = SIMInfo.getInsertedSIMList(mContext);
int simNum = simList.size();
Log.d(TAG, "simList.size() == " + simNum);
long simId = -1;
for (int i = 0; i < simNum; i++) {
simId = simList.get(i).mSimId;
persistRingtoneUriToDatabase(mActiveProfileKey,AudioProfileManager.TYPE_RINGTONE, simId,systemUri);
}
} else {
activeState.mRingerStream = systemUri;
persistRingtoneUriToDatabase(mActiveProfileKey,AudioProfileManager.TYPE_RINGTONE,mSimId,systemUri);
Log.d(…);
}
} else {
Log.d(…);
}
break;
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved