Example usage for android.media RingtoneManager EXTRA_RINGTONE_SHOW_DEFAULT

List of usage examples for android.media RingtoneManager EXTRA_RINGTONE_SHOW_DEFAULT

Introduction

In this page you can find the example usage for android.media RingtoneManager EXTRA_RINGTONE_SHOW_DEFAULT.

Prototype

String EXTRA_RINGTONE_SHOW_DEFAULT

To view the source code for android.media RingtoneManager EXTRA_RINGTONE_SHOW_DEFAULT.

Click Source Link

Document

Given to the ringtone picker as a boolean.

Usage

From source file:Main.java

/**
 * get ringtone list/*  w  ww .j av  a 2s .  c o  m*/
 * @return
 */
public static Intent getRingtoneIntent() {
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALL);

    return intent;
}

From source file:org.kontalk.ui.prefs.NotificationFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences_notification);

    // set ringtone
    final Preference setRingtone = findPreference("pref_ringtone");
    setRingtone.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//from  ww  w .jav a 2s .  co  m
        public boolean onPreferenceClick(Preference preference) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(preference.getContext());

            String _currentRingtone = prefs.getString(preference.getKey(),
                    getString(R.string.pref_default_ringtone));
            Uri currentRingtone = !TextUtils.isEmpty(_currentRingtone) ? Uri.parse(_currentRingtone) : null;

            final Intent i = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentRingtone);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                    RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));

            i.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
            i.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, preference.getTitle());

            startActivityForResult(i, REQUEST_PICK_RINGTONE);
            return true;
        }
    });

    // notification LED color
    final Preference notificationLed = findPreference("pref_notification_led_color");
    notificationLed.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Context context = getContext();
            int[] ledColors = new int[] { ContextCompat.getColor(context, android.R.color.white),
                    ContextCompat.getColor(context, R.color.blue_light),
                    ContextCompat.getColor(context, R.color.purple_light),
                    ContextCompat.getColor(context, R.color.green_light),
                    ContextCompat.getColor(context, R.color.yellow_light),
                    ContextCompat.getColor(context, R.color.red_light), };

            try {
                new ColorChooserDialog.Builder((BasePreferencesActivity) getActivity(),
                        R.string.pref_notification_led_color).customColors(ledColors, null)
                                .preselect(Preferences.getNotificationLEDColor(getContext()))
                                .allowUserColorInput(false).dynamicButtonColor(false).show();
            } catch (IllegalStateException e) {
                // fragment is being destroyed - ignore
            }
            return true;
        }
    });
}

From source file:org.proninyaroslav.libretorrent.settings.BehaviorSettingsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final SettingsManager pref = new SettingsManager(getActivity().getApplicationContext());

    String keyTorrentFinishNotify = getString(R.string.pref_key_torrent_finish_notify);
    SwitchPreferenceCompat torrentFinishNotify = (SwitchPreferenceCompat) findPreference(
            keyTorrentFinishNotify);//from   w  w  w .j  a  va  2  s. co m
    torrentFinishNotify.setChecked(pref.getBoolean(keyTorrentFinishNotify, true));
    bindOnPreferenceChangeListener(torrentFinishNotify);

    String keyPlaySound = getString(R.string.pref_key_play_sound_notify);
    SwitchPreferenceCompat playSound = (SwitchPreferenceCompat) findPreference(keyPlaySound);
    playSound.setChecked(pref.getBoolean(keyPlaySound, true));
    bindOnPreferenceChangeListener(playSound);

    final String keyNotifySound = getString(R.string.pref_key_notify_sound);
    Preference notifySound = findPreference(keyNotifySound);
    String ringtone = pref.getString(keyNotifySound,
            RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString());
    notifySound
            .setSummary(RingtoneManager.getRingtone(getActivity().getApplicationContext(), Uri.parse(ringtone))
                    .getTitle(getActivity().getApplicationContext()));
    /* See https://code.google.com/p/android/issues/detail?id=183255 */
    notifySound.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                    Settings.System.DEFAULT_NOTIFICATION_URI);

            String curRingtone = pref.getString(keyNotifySound, null);
            if (curRingtone != null) {
                if (curRingtone.length() == 0) {
                    // Select "Silent"
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
                } else {
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(curRingtone));
                }

            } else {
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
                        Settings.System.DEFAULT_NOTIFICATION_URI);
            }

            startActivityForResult(intent, REQUEST_CODE_ALERT_RINGTONE);

            return true;
        }
    });

    String keyLedIndicator = getString(R.string.pref_key_led_indicator_notify);
    SwitchPreferenceCompat ledIndicator = (SwitchPreferenceCompat) findPreference(keyLedIndicator);
    ledIndicator.setChecked(pref.getBoolean(keyLedIndicator, true));
    bindOnPreferenceChangeListener(ledIndicator);

    String keyLedIndicatorColor = getString(R.string.pref_key_led_indicator_color_notify);
    LightPreference ledIndicatorColor = (LightPreference) findPreference(keyLedIndicatorColor);
    ledIndicatorColor.forceSetValue(pref.getInt(keyLedIndicatorColor,
            ContextCompat.getColor(getActivity().getApplicationContext(), R.color.primary)));
    bindOnPreferenceChangeListener(ledIndicatorColor);

    String keyVibration = getString(R.string.pref_key_vibration_notify);
    SwitchPreferenceCompat vibration = (SwitchPreferenceCompat) findPreference(keyVibration);
    vibration.setChecked(pref.getBoolean(keyVibration, true));
    bindOnPreferenceChangeListener(vibration);

    String keyAutostart = getString(R.string.pref_key_autostart);
    SwitchPreferenceCompat autostart = (SwitchPreferenceCompat) findPreference(keyAutostart);
    autostart.setChecked(pref.getBoolean(keyAutostart, false));
    bindOnPreferenceChangeListener(autostart);

    String keyShutdownComplete = getString(R.string.pref_key_shutdown_downloads_complete);
    SwitchPreferenceCompat shutdownComplete = (SwitchPreferenceCompat) findPreference(keyShutdownComplete);
    shutdownComplete.setChecked(pref.getBoolean(keyShutdownComplete, false));
    bindOnPreferenceChangeListener(shutdownComplete);

    String keyCpuSleep = getString(R.string.pref_key_cpu_do_not_sleep);
    SwitchPreferenceCompat cpuSleep = (SwitchPreferenceCompat) findPreference(keyCpuSleep);
    cpuSleep.setChecked(pref.getBoolean(keyCpuSleep, false));
    bindOnPreferenceChangeListener(cpuSleep);

    String keyOnlyCharging = getString(R.string.pref_key_download_and_upload_only_when_charging);
    SwitchPreferenceCompat onlyCharging = (SwitchPreferenceCompat) findPreference(keyOnlyCharging);
    onlyCharging.setChecked(pref.getBoolean(keyOnlyCharging, false));
    bindOnPreferenceChangeListener(onlyCharging);

    String keyBatteryControl = getString(R.string.pref_key_battery_control);
    SwitchPreferenceCompat batteryControl = (SwitchPreferenceCompat) findPreference(keyBatteryControl);
    batteryControl.setSummary(
            String.format(getString(R.string.pref_battery_control_summary), Utils.getDefaultBatteryLowLevel()));
    batteryControl.setChecked(pref.getBoolean(keyBatteryControl, false));
    bindOnPreferenceChangeListener(batteryControl);
}

From source file:com.microsoft.mimickeralarm.settings.RingtonePreference.java

private void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, getRingtone());
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
            GeneralUtilities.defaultRingtone());
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALL);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getTitle());
}

From source file:org.proninyaroslav.libretorrent.settings.AppearanceSettingsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final SettingsManager pref = new SettingsManager(getActivity().getApplicationContext());

    String keyTheme = getString(R.string.pref_key_theme);
    ListPreference theme = (ListPreference) findPreference(keyTheme);
    int type = pref.getInt(keyTheme, Integer.parseInt(getString(R.string.pref_theme_light_value)));
    theme.setValueIndex(type);//from   ww w. j a  v  a  2s.c  o  m
    String typesName[] = getResources().getStringArray(R.array.pref_theme_entries);
    theme.setSummary(typesName[type]);
    bindOnPreferenceChangeListener(theme);

    String keyTorrentFinishNotify = getString(R.string.pref_key_torrent_finish_notify);
    SwitchPreferenceCompat torrentFinishNotify = (SwitchPreferenceCompat) findPreference(
            keyTorrentFinishNotify);
    torrentFinishNotify.setChecked(pref.getBoolean(keyTorrentFinishNotify, true));
    bindOnPreferenceChangeListener(torrentFinishNotify);

    String keyPlaySound = getString(R.string.pref_key_play_sound_notify);
    SwitchPreferenceCompat playSound = (SwitchPreferenceCompat) findPreference(keyPlaySound);
    playSound.setChecked(pref.getBoolean(keyPlaySound, true));
    bindOnPreferenceChangeListener(playSound);

    final String keyNotifySound = getString(R.string.pref_key_notify_sound);
    Preference notifySound = findPreference(keyNotifySound);
    String ringtone = pref.getString(keyNotifySound,
            RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION).toString());
    notifySound
            .setSummary(RingtoneManager.getRingtone(getActivity().getApplicationContext(), Uri.parse(ringtone))
                    .getTitle(getActivity().getApplicationContext()));
    /* See https://code.google.com/p/android/issues/detail?id=183255 */
    notifySound.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                    Settings.System.DEFAULT_NOTIFICATION_URI);

            String curRingtone = pref.getString(keyNotifySound, null);
            if (curRingtone != null) {
                if (curRingtone.length() == 0) {
                    // Select "Silent"
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
                } else {
                    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(curRingtone));
                }

            } else {
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
                        Settings.System.DEFAULT_NOTIFICATION_URI);
            }

            startActivityForResult(intent, REQUEST_CODE_ALERT_RINGTONE);

            return true;
        }
    });

    String keyLedIndicator = getString(R.string.pref_key_led_indicator_notify);
    SwitchPreferenceCompat ledIndicator = (SwitchPreferenceCompat) findPreference(keyLedIndicator);
    ledIndicator.setChecked(pref.getBoolean(keyLedIndicator, true));
    bindOnPreferenceChangeListener(ledIndicator);

    String keyLedIndicatorColor = getString(R.string.pref_key_led_indicator_color_notify);
    ColorPreference ledIndicatorColor = (ColorPreference) findPreference(keyLedIndicatorColor);
    ledIndicatorColor.forceSetValue(pref.getInt(keyLedIndicatorColor,
            ContextCompat.getColor(getActivity().getApplicationContext(), R.color.primary)));
    bindOnPreferenceChangeListener(ledIndicatorColor);

    String keyVibration = getString(R.string.pref_key_vibration_notify);
    SwitchPreferenceCompat vibration = (SwitchPreferenceCompat) findPreference(keyVibration);
    vibration.setChecked(pref.getBoolean(keyVibration, true));
    bindOnPreferenceChangeListener(vibration);
}

From source file:org.isoron.uhabits.helpers.ReminderHelper.java

public static void startRingtonePickerActivity(Fragment fragment, int requestCode) {
    Uri existingRingtoneUri = ReminderHelper.getRingtoneUri(fragment.getContext());
    Uri defaultRingtoneUri = Settings.System.DEFAULT_NOTIFICATION_URI;

    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, defaultRingtoneUri);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, existingRingtoneUri);
    fragment.startActivityForResult(intent, requestCode);
}

From source file:com.mattprecious.notisync.profile.SecondaryCustomProfileActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.profile_custom_secondary);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    dbAdapter = new DbAdapter(this);

    if (getIntent().hasExtra("profile")) {
        profile = getIntent().getParcelableExtra("profile");
    } else {/*from w  w  w  .  j av  a  2  s .c  o  m*/
        profile = new SecondaryProfile();
        profile.setEnabled(true);
        profile.setVibrate(true);
        profile.setLed(true);
    }

    nameField = (EditText) findViewById(R.id.nameField);
    nameField.setText(profile.getName());
    nameField.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                validateName();

                if (tagField.getText().length() == 0) {
                    tagField.setText(nameField.getText().toString().toLowerCase(Locale.getDefault())
                            .replaceAll("\\s", ""));
                    validateTag();
                }
            }
        }

    });

    tagField = (EditText) findViewById(R.id.tagField);
    tagField.setText(profile.getTag());
    tagField.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                validateTag();
            }

        }

    });

    tagRequestButton = (ImageButton) findViewById(R.id.tagRequestButton);
    tagRequestButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            SherlockDialogFragment newFragment = new RequestTagsDialogFragment();
            newFragment.show(getSupportFragmentManager(), null);
        }

    });

    unconnectedOnlyCheckBox = (CheckBox) findViewById(R.id.unconnectedOnlyCheckBox);
    unconnectedOnlyCheckBox.setChecked(profile.isUnconnectedOnly());

    ringtoneSelector = (Button) findViewById(R.id.ringtoneSelector);
    ringtoneSelector.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                    RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, getRingtoneUri(profile.getRingtone()));

            startActivityForResult(intent, REQUEST_CODE_RINGTONE_PICKER);

        }
    });

    vibrateCheckBox = (CheckBox) findViewById(R.id.vibrateCheckBox);
    vibrateCheckBox.setChecked(profile.isVibrate());

    checkForVibrator();

    lightsCheckBox = (CheckBox) findViewById(R.id.lightsCheckBox);
    lightsCheckBox.setChecked(profile.isLed());

    updateRingtoneSelector();
}

From source file:rikka.materialpreference.RingtonePreference.java

/**
 * Prepares the intent to launch the ringtone picker. This can be modified
 * to adjust the parameters of the ringtone picker.
 *
 * @param ringtonePickerIntent The ringtone picker intent that can be
 *            modified by putting extras.
 *///from  w ww. j  av  a2s  .co m
protected void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {

    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, onRestoreRingtone());

    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, mShowDefault);
    if (mShowDefault) {
        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                RingtoneManager.getDefaultUri(getRingtoneType()));
    }

    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, mShowSilent);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, mRingtoneType);
    ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getTitle());
}

From source file:org.schabi.terminightor.AlarmItemDetailFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    lastSavedInstaneState = savedInstanceState;
    Activity a = getActivity();/*  w  ww  .  j a v  a  2s  .  c  o  m*/
    setAlarmTimeView = (TextView) a.findViewById(R.id.setAlarmTimeView);
    setAlarmAMPMView = (TextView) a.findViewById(R.id.setAlarmAmPmSuffix);
    repeatCheckBox = (CheckBox) a.findViewById(R.id.setRepeatCheckBox);
    chooseDateView = (ChooseDaysView) a.findViewById(R.id.chooseDateView);
    alarmLabelBox = (EditText) a.findViewById(R.id.setAlarmLabelBox);
    setAlarmToneButton = (Button) a.findViewById(R.id.setAlarmToneButton);
    vibrateCheckBox = (CheckBox) a.findViewById(R.id.vibrateCheckBox);
    nfcTagLabelView = (ImageView) a.findViewById(R.id.nfcTagLabelView);
    nfcTagIdView = (TextView) a.findViewById(R.id.nfcTagIdView);
    addNfcTabButton = (FloatingActionButton) a.findViewById(R.id.addNfcTagButton);

    repeatCheckBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (repeatCheckBox.isChecked()) {
                chooseDateView.setVisibility(View.VISIBLE);
            } else {
                chooseDateView.setVisibility(View.GONE);
            }
            chooseDateView.setRepeatEnabled(repeatCheckBox.isChecked());
        }
    });

    setAlarmTimeView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            timePickerDialog.show();
        }
    });

    setAlarmToneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,
                    getResources().getString(R.string.selectAlarmToneTitle));
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
            intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
            if (!alarm.getAlarmTone().isEmpty()) {
                intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(alarm.getAlarmTone()));
            }
            startActivityForResult(intent, SET_ALARM_TONE);
        }
    });

    addNfcTabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), SetTagActivity.class);
            startActivityForResult(intent, READ_NFC_ID);
        }
    });
}

From source file:com.example.mydemos.view.RingtonePickerActivity.java

/** Called when the activity is first created. */
@Override/*from  ww w  .j av a 2s  .c o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.ringtone_picker);
    CharSequence sysTitle = (CharSequence) getResources().getText(R.string.sys_tone);
    CharSequence MusicTitle = (CharSequence) getResources().getText(R.string.sd_music);
    CharSequence RecordTitle = (CharSequence) getResources().getText(R.string.record_tone);
    Intent intent = getIntent();
    toneType = intent.getIntExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, -1);

    Log.e("duwenhua", "ringPick get toneType:" + toneType);

    //! by duwenhua
    //if(toneType == RingtoneManager.TYPE_RINGTONE_SECOND)
    //    toneType = RINGTONE_TYPE;

    //! by duwenhua
    mHasDefaultItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
    mUriForDefaultItem = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI);
    //Log.i("lys", "mUriForDefaultItem == " + mUriForDefaultItem);
    if (savedInstanceState != null) {
        mSelectedId = savedInstanceState.getLong(SAVE_CLICKED_POS, -1);
    }
    //Log.i("lys", "mUriForDefaultItem 1== " + mUriForDefaultItem+", mSelectedId =="+mSelectedId);      
    mHasSilentItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
    mExistingUri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI);
    //if(mUriForDefaultItem != null)
    //{
    //    mSelectedId = ContentUris.parseId(mUriForDefaultItem);
    //}

    //Log.i("lys", "RingtonePickerActivity.java onCreate mExistingUri == " + mExistingUri);   
    //String action = getIntent().getAction();
    //Log.i("lys", "PT Intent action == " + action);

    if (toneType == NOTIFICATION_TYPE) {
        mUriForDefaultItem = Settings.System.DEFAULT_NOTIFICATION_URI;
    } else if (toneType == RINGTONE_TYPE) {
        mUriForDefaultItem = Settings.System.DEFAULT_RINGTONE_URI;
    } else if (toneType == ALARM_TYPE) {
        mUriForDefaultItem = Settings.System.DEFAULT_ALARM_ALERT_URI;
    }

    if (isAvailableToCheckRingtone() == true) {
        Ringtone ringtone_DefaultItem = checkRingtone_reflect(this, mUriForDefaultItem, toneType);
        if (ringtone_DefaultItem != null && ringtone_DefaultItem.getUri() != null) {
            mUriForDefaultItem = ringtone_DefaultItem.getUri();
            Log.i("lys", "RingtoneManager.getRingtone  mUriForDefaultItem== " + mUriForDefaultItem);
        } else {
            //mUriForDefaultItem = 'content/medial/';
            /*ZTE_AUDIO_LIYANG 2014/06/30 fix bug for ringtone when remove sdcard start */
            String originalRingtone = Settings.System.getString(getApplicationContext().getContentResolver(),
                    "ringtone_original");
            if (originalRingtone != null && !TextUtils.isEmpty(originalRingtone)) {
                mUriForDefaultItem = Uri.parse(originalRingtone);
                Log.e("liyang", "select riongtone error  ,change to originalRingtone == " + mExistingUri);
            }
            /*ZTE_AUDIO_LIYANG 2014/06/30 fix bug for ringtone when remove sdcard end */
            Log.i("lys", "mUriForDefaultItem set as default mUriForDefaultItem== 222");
        }

        if (mExistingUri != null) {
            Ringtone ringtone = checkRingtone_reflect(this, mExistingUri, toneType);
            if (ringtone != null && ringtone.getUri() != null) {
                //mUriForDefaultItem = ringtone.getUri(); 
                mExistingUri = ringtone.getUri();
                Log.i("lys", "RingtoneManager.getRingtone  mExistingUri== " + mExistingUri);
            } else {
                mExistingUri = mUriForDefaultItem;
                Log.i("lys", "mExistingUri set as default mExistingUri== " + mExistingUri);
            }
        }
    }

    boolean includeDrm = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_INCLUDE_DRM, false);
    Log.e("lys", "includeDrm ==" + includeDrm);
    mRingtoneManager = new RingtoneManager(this);
    mRingtoneManager.setIncludeDrm(includeDrm);
    if (toneType != -1) {
        mRingtoneManager.setType(toneType);
    }

    setVolumeControlStream(mRingtoneManager.inferStreamType());
    //   toneActivityType = mRingtoneManager.getActivityType();
    if (toneType == ALARM_TYPE) {
        sysTitle = (CharSequence) getResources().getText(R.string.alarm_tone);
    } else if (toneType == NOTIFICATION_TYPE) {
        sysTitle = (CharSequence) getResources().getText(R.string.notification_tone);
    }

    listView = new ListView(this);
    listView.setOnItemClickListener(this);
    //listView.setBackgroundColor(#ff5a5a5a);
    listView.setFastScrollEnabled(true);
    //listView.setFastScrollAlwaysVisible(true);
    listView.setEmptyView(findViewById(android.R.id.empty));
    //mHasSilentItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);

    //mHasDefaultItem = true; //temp
    if (mHasDefaultItem) {
        //chengcheng
        addDefaultStaticItem(listView, com.android.internal.R.string.ringtone_default);

    }

    setDefaultRingtone();

    if (mHasSilentItem) {
        // chengcheng
        addSilendStaticItem(listView, com.android.internal.R.string.ringtone_silent);
    }
    audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mAudioFocusListener = new OnAudioFocusChangeListener() {
        public void onAudioFocusChange(int focusChange) {

        }
    };

    okBtn = (Button) findViewById(R.id.ok);
    okBtn.setOnClickListener(this);
    cancelBtn = (Button) findViewById(R.id.cancel);
    cancelBtn.setOnClickListener(this);

    TabHost mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();
    mTabHost.addTab(mTabHost.newTabSpec("tab_system").setIndicator(sysTitle, null).setContent(this));
    mTabHost.addTab(mTabHost.newTabSpec("tab_music").setIndicator(MusicTitle, null).setContent(this));
    mTabHost.addTab(mTabHost.newTabSpec("tab_record").setIndicator(RecordTitle, null).setContent(this));
    mTabHost.setCurrentTab(0);
    mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
        @Override
        public void onTabChanged(String tabId) {
            // stopMediaPlayer();
            createTabContent(tabId);
        }
    });
}