2017-01-10 2 views
2

Je développe une application qui a reçu une notification à un moment donné. J'ai implémenté quelques méthodes pour permettre à l'utilisateur de changer le son de notification. Comment modifier le style de la boîte de dialogue Sélecteur de sonnerie?Modifier le style de dialogue du sélecteur de sonnerie

Ceci est mon code pour le sélecteur de sonnerie:

public void getNotification(){ 
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); 
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); 
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone"); 
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); 
    this.startActivityForResult(intent, 5); 
} 

Je possède déjà un style personnalisé pour les dialogues d'alerte (R.style.AlertDialogCustom). Comment puis-je utiliser ce style personnalisé dans ma boîte de dialogue de sélection de sonnerie?

+0

Je voudrais Je le sais aussi. Avez-vous trouvé une solution? –

+0

En fait, j'ai fait. Je viens de répondre à ma propre question. –

Répondre

0

j'ai réussi à résoudre mon problème en ajoutant cette ligne de code à la méthode ci-dessus:

public void getNotification(){ 
     Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); 
     intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); 
     intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone"); 
     intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, R.style.AlertDialogCustom); //this one 
     intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); 
     this.startActivityForResult(intent, 5); 
    } 

Et cela, il le style correspondant à ma commande AlertDialog:

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert"> 
     <item name="colorPrimary">@color/primary</item> 
     <item name="colorPrimaryDark">@color/maroon</item> 
     <item name="colorAccent">@color/primary</item> 
    </style> 
+0

Ça n'a rien changé dans le mien. Vous passez deux fois EXTRA_RINGTONE_TYPE, n'est-ce pas? L'un prend TYPE_NOTIFICATION et l'autre prend le style, correct? –