Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android 如何設置視頻來電的默認鈴聲

Android 如何設置視頻來電的默認鈴聲

編輯:關於Android編程

 

 

背景: 原始設計語音來電鈴聲和視頻來電鈴聲是一起設置的。即設置的默認鈴聲同時是語音來電和視頻來電的鈴聲。 需求: 只想單獨設置視頻來電的默認鈴聲。 實現思路: 參考原先來電鈴聲的設置機制,給視頻來電鈴聲單獨設置屬性寫默認的鈴聲名稱,然後在文件掃描時,判斷掃描到的文件是設置的默認視頻鈴聲的文件名,則在database中填寫視頻來電的鍵值為此鈴聲; PS:被設置的鈴聲首先要存在於系統中,關於如何添加系統鈴聲請參考”FAQ06323[Audio Profile]如何添加以及刪減特定的默認通知鈴聲,如何設置默認鈴聲”; 1,添加Video Call默認鈴聲的屬性: alpsuild argetproductcore.mk中添加“ro.config.video_call”:
PRODUCT_PROPERTY_OVERRIDES :=
ro.config.notification_sound=Proxima.ogg
ro.config.alarm_alert=Alarm_Classic.ogg
ro.config.ringtone=Backroad.ogg
ro.config.video_call=VideocallRt.ogg
2,添加對掃描到文件的判斷是否是默認Vide Call的默認鈴聲: alps rameworksasemediajavaandroidmediamediascanner.java:
1),添加成員變量用做後面的判斷:
private String mDefaultRingtoneFilename;
private String mDefaultVideocallFilename; private boolean mDefaultRingtoneSet;
private boolean mDefaultVideoCallSet; private static final String RINGTONE_SET = ringtone_set;
private static final String VIDEOCALL_SET = videocall_set;
2):添加讀取video call默認鈴聲的系統屬性: private void setDefaultRingtoneFileNames() {
mDefaultRingtoneFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
+ Settings.System.RINGTONE);
mDefaultVideocallFilename = SystemProperties.get(DEFAULT_RINGTONE_PROPERTY_PREFIX
+ Settings.System.VIDEO_CALL);//add this line
...
} 3):添加對掃描到的文件是否是視頻來電默認鈴聲的判斷: 參考標有//start modify”和//end modify”中間包含的為添加整段code,//add this line和”Modify this line為添加添加的語句和修改的語句。 並請留意“else if (ringtones && doesSettingEmpty(RINGTONE_SET)&&!videocall) {”中要一定注釋掉對VideoCall的設置:
private Uri endFile(){
boolean videocall = false; //add this line
.....
if (notifications &&((mWasEmptyPriorToScan && !mDefaultNotificationSet) ||
doesSettingEmpty(NOTIFICATION_SET))) {
.... //start modify
} else if(ringtones && ((mWasEmptyPriorToScan && (!mDefaultRingtoneSet||!mDefaultVideoCallSet)) || doesSettingEmpty(RINGTONE_SET)|| doesSettingEmpty(VIDEOCALL_SET))) {
if (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
needToSetSettings = true;
/// M: Adds log to debug setting ringtones.
Xlog.v(TAG, endFile: needToSetRingtone=true.);
} if (TextUtils.isEmpty(mDefaultVideocallFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultVideocallFilename)) { needToSetSettings = true;
videocall = true; /// M: Adds log to debug setting ringtones.
Xlog.v(TAG, endFile: needToSetRingtone=true.);
}
} else if (alarms && ((mWasEmptyPriorToScan && !mDefaultAlarmSet) ||
doesSettingEmpty(ALARM_SET))) {
...
} ...
if(needToSetSettings) {
if (notifications && doesSettingEmpty(NOTIFICATION_SET)) {
..... //start modify
} else if (ringtones && (doesSettingEmpty(RINGTONE_SET)||doesSettingEmpty(VIDEOCALL_SET)) { if(videocall){ setSettingIfNotSet(Settings.System.VIDEO_CALL, tableUri, rowId); setProfileSettings(RingtoneManager.TYPE_VIDEO_CALL, tableUri, rowId);
mDefaultVideoCallSet = true;
setSettingFlag(VIDEOCALL_SET);
} else{
setSettingIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
// setSettingIfNotSet(Settings.System.VIDEO_CALL, tableUri, rowId); //modify this line
setSettingIfNotSet(Settings.System.SIP_CALL, tableUri, rowId);
setProfileSettings(RingtoneManager.TYPE_RINGTONE, tableUri, rowId);
// setProfileSettings(RingtoneManager.TYPE_VIDEO_CALL, tableUri, rowId);//modify this line
setProfileSettings(RingtoneManager.TYPE_SIP_CALL, tableUri, rowId);
mDefaultRingtoneSet = true;
setSettingFlag(RINGTONE_SET); }
Xlog.v(TAG, endFile: set ringtone. uri= + tableUri + , rowId= + rowId); //end modify
}else if (alarms && doesSettingEmpty(ALARM_SET)) {
....
}

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved