Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Disclaimer popping up after every intent
    primarykey
    data
    text
    <p>Just a bit about my app first. Its a quiz app. It has a main screen displaying a question, which loads straight away, and arrows going <code>previous</code> and <code>next</code> which go to other quiz questions. I'm using the same layout over and over, just by passing different question data, so when I click the "next" button, it will just launch an <code>intent</code> to the same class, just with different data. At the start of my one single layout, I have a little check to see if the user has clicked to hide the disclaimer or not. </p> <p>So my disclaimer pops up at the start of the app. It has a <code>dismiss</code> button and a <code>Dont show this again</code> checkbox. I can get the checkbox working perfect, using <code>SharedPreferences</code> but the problem arises when they hit the <code>Dismiss</code> button. Since I'm reusing the same layout, any time the user navigates to a new question, the disclaimer pops up. I only want it to popup on the first screen, e.g. when the app loads.</p> <p>I have tried setting another <code>SharedPreference</code> to hide the disclaimer when the user hits <code>dismiss</code> but once I hide it, it never comes back, because when the user loads the app back up again, that shared preference is still set. My problem is knowing where to set the preference back! I tried resetting it in <code>onPause()</code> but that didn't work.</p> <p>So, what I'm asking is, how can I determine if an activity is the first one to be loaded so I can only do the Disclaimer check then, and not in each of the subsequent screens?</p> <p>Thanks.</p> <p>EDIT: Here's my <code>OnCreate()</code> method:</p> <pre><code>final static String disclaimerShownPref = "disclaimerShown"; final static String disclaimerShownOnce = "disclaimerShownThisSession"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); //Checks to see if the boolean is set //The second argument is the default to use if the preference can't be found if(!mPrefs.getBoolean(disclaimerShownPref, false)) { if(!mPrefs.getBoolean(disclaimerShownOnce, true)) { new Disclaimer(this); } } topMostLayout=buildHomeScreen(); setContentView(topMostLayout); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload