How to set ringtone with RingtoneManager.ACTION_RINGTONE_PICKER?

后端 未结 4 1152
Happy的楠姐
Happy的楠姐 2020-11-30 01:53

I try to find solution here, but there are only solution for own/selected file, not for code when I call picker. I use following code when user press button:



        
4条回答
  •  日久生厌
    2020-11-30 02:40

    You must implement onActivityResult() to receive result from user's pick, then save it.

    if (resultCode == RESULT_OK) {
        Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
        if (uri != null) {
        String ringTonePath = uri.toString();
    }
    

    Here an example: http://www.ceveni.com/2009/07/ringtone-picker-in-android-with-intent.html

    EDIT: update

    RingtoneManager.setActualDefaultRingtoneUri(
        myActivity,
        RingtoneManager.TYPE_RINGTONE,
        uri);
    

    You must call this :)

提交回复
热议问题