1. 程式人生 > >Android 6.0新增自定義鈴聲

Android 6.0新增自定義鈴聲

 預設在android M版本鈴聲設定對話方塊裡面包含“更多鈴聲”選項。在N版本也包含這項,只是未讓它顯示。鈴聲設定對話方塊程式碼在packages/providers/MediaProvider/src/com/android/providers/media/RingtonePickerActivity.java。onCreate函式
 /// M: Get whether to show the 'More Ringtones' item
 mHasMoreRingtonesItem = intent.getBooleanExtra(
     RingtoneManager.EXTRA_RINGTONE_SHOW_MORE_RINGTONES, false);
 啟動RingtonePickerActivity的時候把RingtoneManager.EXTRA_RINGTONE_SHOW_MORE_RINGTONES設定成true。在/packages/apps/Settings/src/com/android/settings/RingtonePreference.java檔案的onPrepareRingtonePickerIntent新增程式碼     //add
 ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_MORE_RINGTONES, true);

 
    \80_c_m\alps\packages\apps\Settings\src\com\android\settings\DefaultRingtonePreference.java
    \80_c_m\alps\packages\apps\Settings\src\com\mediatek\audioprofile\DefaultRingtonePreference.java
@Override
    protected void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {
        super.onPrepareRingtonePickerIntent(ringtonePickerIntent);
        
        /*
         * Since this preference is for choosing the default ringtone, it
         * doesn't make sense to show a 'Default' item.
         */
        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, false);
       
       ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_MORE_RINGTONES, true);

   // 新增
      
    }

在80_c_m\update\jinhuima\v117_hd720p_s006d_b1_1GB_16GB_2d2\packages\providers\MediaProvider\src\com\android\providers\media\RingtonePickerActivity.java
   onCreate方法中新增
   mHasMoreRingtonesItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_MORE_RINGTONES, true);