java - sharedpreference with splash screen -


my app start splash screen music , used sharedpreference stop music next time open app splash screen still there without music .

im trying preference screen 3 independent different checked box functions , if check 1 checkedbox can not check other 2 below :

first checkedbox: start app splash screen , music ( achieved below code ) ,

second checkedbox: start app splash screen , without music ( achieved below code ) ,

third checkedbox: start app without splash screen , music ( not achieved ) .

any appreciated ,

the code :

splash :

 public class splash extends activity{       mediaplayer oursong; @override protected void oncreate(bundle savedinstancestate) {     this.requestwindowfeature(window.feature_no_title);      // todo auto-generated method stub     super.oncreate(savedinstancestate);          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(1000); }           catch (interruptedexception e){             e.printstacktrace(); }           finally{         intent openmainactivity = new intent("com.test.demo.menu");                 startactivity(openmainactivity); }}                                                                      };                 timer.start();   }  @override protected void onpause() {             // todo auto-generated method stub     super.onpause();     oursong.release();     finish();           }         } 

prefs :

public class prefs extends preferenceactivity{  @suppresswarnings("deprecation") @override protected void oncreate(bundle savedinstancestate) {     boolean customtitlesupported = requestwindowfeature                  (window.feature_custom_title);         // todo auto-generated method stub     super.oncreate(savedinstancestate);     addpreferencesfromresource(r.xml.prefs);                                             }                            } 

prefs.xml:

  <?xml version="1.0" encoding="utf-8" ?>       <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android">           <checkboxpreference android:title="splash screen music"                    android:defaultvalue="true"                    android:key="checkbox"                    android:summary="remove mark stop music when splash start" />       </preferencescreen> 

    sharedpreferences getprefs =preferencemanager.getdefaultsharedpreferences(getbasecontext());     boolean music = getprefs.getboolean("checkbox");     if (music == true)       {         setcontentview(r.layout.splash);           oursong = mediaplayer.create(splash.this, r.raw.splashsound);                 oursong.start();         thread timer = new thread()         {             public void run()             {                 try                 {                     sleep(1000);                  }                 catch (interruptedexception e)                 {                     e.printstacktrace();                  }                                 {                     intent openmainactivity = new intent("com.test.demo.menu");                     startactivity(openmainactivity);                  }             }                                   };         timer.start();        } } else {     intent openmainactivity = new intent("com.test.demo.menu");     startactivity(openmainactivity); } 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -