From what I can understand, you want the following:
a. the user selects one of the flags, and the other two - false
V. when launching the application, it checks the preferences and will play / not play music, show / not show the screensaver.
To achieve A you need to use the onPreferenceChange method. In this method, you will check if the preference has changed, true if it is set by two other preferences equal to false. The problem occurs if all three parameters are false, in which case you need to either set the default preference or perform the default action in the Splash Activity class.
This should make sure that one preference is set to true. I would put three preferences in the preference category to show the user with whom they are grouped. The preferred way to handle this case would be a group of switches that would always provide a single option.
C. In your Splash activity, I would retrieve the call to start the next action using a separate method (move finish () for this method), and then in the onCreate () method, check the preference settings. If the preference is to skip the splash, make a call to the startNextActivity method, otherwise enter a wait stream and continue the onResume () method with the appropriate music settings.
You did not include onResume () code in the sample code, here you should start the music. I would also move the call to stop the music and end () to the extracted startNextActivity () method.
Instead of using Thread to start the timer, use something like this that will help maintain smoothness and move the timer from the main thread.
new Handler().postDelayed(new Runnable() { public void run() { startNextActivity(); } }, SPLASH_DISPLAY_LENGTH);
Hope this helps.
source share