i am working on the an Application where i have to turn on or off the music using SwitchPreference
i have searched a lot but could not find any help of my level
i do not know how to do some thing when the SwitchPreference is Changed
the code is given below
<?xml version="1.0" encoding="utf-8"?>
<SwitchPreference
android:key="sound"
android:summaryOff="Sound is Off"
android:summaryOn="Sound is On"
android:title="Sound" >
</SwitchPreference>
<SwitchPreference
android:key="Music"
android:summaryOff="Music is Off"
android:summaryOn="Music is On"
android:title="background Music" >
</SwitchPreference>
<CheckBoxPreference
android:key="Time"
android:summaryOff="Time Reduced to 1 mint"
android:summaryOn="Time increased to 1:40 mint"
android:title="Minimum Time" >
</CheckBoxPreference>
the preferences class is here
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.SwitchPreference;
import android.util.Log;
public class PrefrencesClass extends PreferenceActivity{
backGroundMusic bckMusic = new backGroundMusic();
SwitchPreference swichpref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref);
swichpref = (SwitchPreference) findPreference("Music");
}
}
in the mainClass i Called this like this
public void onClick(View v) {
switch (v.getId()) {
case R.id.setting:
Intent prefIntent = new Intent(this,PrefrencesClass.class);
startActivity(prefIntent);
break;
}}
what is next
please help