title: How to do a global override to a method?
body: <p>I have declared a global boolean variable in my MainActivity class and set its value to true:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      public boolean inAppTextIntegration = true;
      //onCreate method and stuff
  </code></pre>
  
  <p>I have 11 more activities in my application. And, in every activity, I'm overriding the attachBaseContext method as:</p>
  
  <pre><code>@Override
  protected void attachBaseContext(Context base) {
      if(inAppTextIntegration) {
          super.attachBaseContext(ZeTarget.attachBaseContext(base, this));
      }
      else {
          super.attachBaseContext(base);
      }
  }
  </code></pre>
  
  <p>I have declared the boolean variable <code>inAppTextIntegration</code> in all my activities. Now the problem part: Since I'm doing the same thing in all the activities, <strong>is it possible to reduce the code</strong>?</p>
  
  <p>Currently, I'm using <code>SharedPreferences</code> to store the value of <code>inAppTextIntegration</code> in my MainActivity, and then accessing that value in other activities because I don't want to set this value manually in all the activities. </p>
  
  <p>Again, the problem that I face is in all other activities, <code>else</code> part of the overriding method is being executed (I'm initializing <code>inAppTextIntegration</code> variable in <code>onCreate</code> method of all other activities. Doing it outside the onCreate method causes null pointer exception as the context is not set yet).</p>
  
  <p>So, <strong>how do I control the override to <code>attachBaseContext</code> at all other activities just by changing one variable in the MainActivity</strong>?</p>