Naruto
Naruto

Reputation: 9634

Ringtone picker returns null intent always

i'm trying to read the value from ringtone picker, but in onactivityresult i get NULL intent.

Here is the code i use to launch the ringtone picker

    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:");
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,RingtoneManager.TYPE_NOTIFICATION);
    startActivityForResult(intent,999);

Here i get NULL as response in onactivityresult, with response code requestCode as 100. resultcode 0

requestCode should be 999 but i get 100.

@Override  
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        //Data i get as NULL, it should be valid intent 
       super.onActivityResult(requestCode, resultCode, data);

        switch (requestCode) {

        case 100:

Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);

         }
} 

Upvotes: 0

Views: 872

Answers (1)

fuzzyBatman
fuzzyBatman

Reputation: 41

I know this is REALLY late, but this is how it needs to be done

Uri pickedUri= (Uri) data.getExtras().get(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);

Upvotes: 3

Related Questions