title: How can I use getSupportActionBar() is to make changes from another class
body: <p><strong>UPDATE:</strong> Edited with working code!</p>
  
  <p>I have a class (<code>ColorChanger</code>) where I'm trying to change the color of the actionbars from other activities, except <code>getSupportActionBar()</code> is undefined from my <code>ColorChanger</code> class. How can I do this properly?</p>
  
  <p>Working code from <code>ColorChanger</code>:</p>
  
  <pre><code>public void changeColor(int newColor, Context context, Activity activity) {
  
      this.mActivity = activity;
      Drawable colorDrawable = new ColorDrawable(newColor);
      Drawable bottomDrawable = context.getResources().getDrawable(
              R.drawable.actionbar_bottom);
      LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable,
              bottomDrawable });
  
      if (oldBackground == null) {
  
          this.mActivity.getSupportActionBar().setBackgroundDrawable(ld);
  
      } else {
  
          TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                  oldBackground, ld });
  
          this.mActivity.getSupportActionBar().setBackgroundDrawable(td);
  
          td.startTransition(200);
  
      }
  
      oldBackground = ld;
  
      this.mActivity.getSupportActionBar().setDisplayShowTitleEnabled(false);
      this.mActivity.getSupportActionBar().setDisplayShowTitleEnabled(true);
  
      currentColor = newColor;
  
  }
  </code></pre>
  
  <p>If you need more code, just ask.</p>