Hey there.
Well we created our first setting a setting that allows you to mute and undue the sound and then let's
create a setting that will allow you to choose a ringtone as you remember we have three wires in the
roll folder with different sounds.
Of course we could use the example element check box preference.
We could create some checkboxes
what zoo.
Three more checkbox preference and we could title them for example bail the first default melody
and the second Ahlam Ceren could be called
and the third BEEP
And now let's run and see how it will be displayed.
As you see three more settings appeared in which we could also turn off and on the checkboxes.
But in these savings in the checkbox they can be selected all together.
And this does not suit us.
Now we need one melody to be selected and for this case it is better to use another element of preference
police preference.
Let me remove the extra checkbox preference.
The only one that controls the sound.
And here I write this preference
and there again.
Here we will write title for example time melody
the key will also specify time or melody and the default value will be set to Bill.
We are already familiar with these attributes and we need to add two more attributes that we did not
to use in their checkbooks preference.
These are Android entries and the second attribute is Android and true values and in these attributes
we must specify to our race one array will be the names of our tunes so far melodies which will be displayed
in the settings and the second array of venture values will contain a value for each of these names
which will be stored in the shared preference spot.
Let's start by creating another example while in the ballots folder value resource file.
Let's call it a race click or key and apply arrays.
X and Melissa created an inside this file.
We need to place these two arrays the first array will be called for example prev shortfall.
Preference yes or preference timer melody.
Labels
and inside we need to put the value of this array using the item elements.
The first one will be Belle.
Then copy and paste two more.
The second will be all on Syrian
and the second B or on the third.
Sorry babe.
And the second array must be set specified.
Let's call it break time and Melody values
and also add three elements yes.
Here you need to specify values in the name of the array.
And here we specify the value with a small item
and I want to draw your attention to the fact that the order in this and this array should be the same.
That is well armed Syrian.
Beep.
I hear two bell siren and beep.
And then here we specify the names of our arrays.
The first is prayer for time a melody labels.
We write at array add prep time and Melody labels and the second at array values.
And let's check how it will look in the application.
And if we click on the time a melody window appear in which we can select a melody
any option or cancel
and now or we need to link the setting of our melody with our file share preferences.
To do this in the main activity when setting the melody we must make a check that is after this if if
sound enabled the sound is enabled we create a variable of type String.
Call it Melody name
and assign it shared preferences get string then we specify then draw it key time and melody
and by default.
Well that's a bell.
Put a symbol and then we check the melody name equals Bell and then oh we set this melody.
Next ls
will delete this code and copy these but
and then another branch since we have three melodies.
That is well we have three branches for each melody.
Next all Syrian value let's scope it
and let's paste here and there.
Let's see what the name or the file all on Syrian sound is called.
Then we turn it on and the next if beep.
And then we made sound and meet the play start.
We also need to put this line on each of the branches.
Oh no.
Let's check if everything works for us
yeah.
Now all I'm Syrian.
Let's leave it and try to run.
Great work.
Let's try to install the next one.
All works cool.