I create Preference activity on my app to allow user to start/stop background splash screen music as follow :
public class Prefs extends PreferenceActivity{
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
}
}
and inside xml folder create prefs.xml :
<?xml version="1.0" encoding="utf-8" ?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:title="splash music"
android:defaultValue="true"
android:key="checkbox"
android:summary="Plese remove music "/>
</PreferenceScreen>
and this code for splash activity :
public class Splash extends Activity{
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle Drandroid) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// TODO Auto-generated method stub
super.onCreate(Drandroid);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.splashsound);
SharedPreferences getPrefs =
PreferenceManager.getDefaultSharedPreferences(getBaseContext());
boolean music = getPrefs.getBoolean("checkbox", true);
if (music == true)
ourSong.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000); }
catch (InterruptedException e){
e.printStackTrace(); }
finally{
Intent openTurkeyTrip = new Intent("com.android.dr.MENU");
startActivity(openplanet); }}
};
timer.start(); }
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}
how can i solve it with other class which is not deprecated also my app will support old and new devices as below :
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
any advice will be appreciated, thanks.