title: onCreate method variables unaccessible?
body: <p>I'm still struggling to find a clean easy way to load some values in my onCreate method and pass them to another class in order that a game may load and save option settings.</p>
  
  <p>I can successfully retrieve and change values from my other class but the problem is, no matter what I try, variable set in the onCreate method will not carry to the rest of the code.</p>
  
  <p>I take the point that by only showing snipits of the code I may have obscured the problem but my original is far to massive and sprawling to post HOWEVER it was based on a great tutorial by Martin
  <a href="http://www.droidnova.com/android-3d-game-tutorial-part-i,312.html" rel="nofollow">http://www.droidnova.com/android-3d-game-tutorial-part-i,312.html</a></p>
  
  <p>So I've returned to first principles and just added the problematic portion to that tutorial code and my problem has been replicated. So here is the complete code:</p>
  
  <p><em><strong></em> Vortex.java **</strong></p>
  
  <pre><code>package com.clockworkrobot.vortex;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  public class Vortex extends Activity {
      private static final String LOG_TAG = Vortex.class.getSimpleName();
      private VortexView _vortexView;
  
      private float _red ;  // these are the values that actually reach VortexRender class
      private float _green = 1f ; // touch the screen, it will turn green.
      private float _blue ;  // but why don't the variable in my onCreate override these?
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          _red = 1f;    // The test values I want to reach my Vortex Renderer class.
          _green = 0f;  // to help debug. they should make the screen magenta
          _blue = 1f;  // Eventually these value will be loaded during onCreate
  
         setRed(_red);  // I don't think these are needed 
         setGreen(_green); // But since the variable within this method
         setBlue(_blue); // don't appear to be reaching their target..worth a try
  
          _vortexView = new VortexView(this);
          setContentView(_vortexView);
      }
  
      public float getRed() {
          return _red;       
      }
  
      public void setRed(float value) {
          _red = value;
      }
  
      public float getGreen() {
          return _green;       
      }
  
      public void setGreen(float value) {
          _green = value;
      }
  
      public float getBlue() {
          return _blue;       
      }
  
      public void setBlue(float value) {
          _blue = value;
      }
  
  
  }
  </code></pre>
  
  <p><em><strong></em> VortexRender.java**</strong></p>
  
  <pre><code>package com.clockworkrobot.vortex;
  
  import javax.microedition.khronos.egl.EGLConfig;
  import javax.microedition.khronos.opengles.GL10;
  
  import android.app.Activity;
  import android.opengl.GLSurfaceView;
  import android.os.Bundle;
  
  public class VortexRenderer extends Activity implements GLSurfaceView.Renderer {
  private static final String LOG_TAG = VortexRenderer.class.getSimpleName();
  
   //   Vortex sw = new Vortex();
  
  private Vortex sw;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      sw = new Vortex();
  }
  
      private float _red = 0f;
      private float _green = 0f;
      private float _blue = 0f;
  
      @Override
      public void onSurfaceCreated(GL10 gl, EGLConfig config) {
          // Do nothing special.
      }
  
      @Override
      public void onSurfaceChanged(GL10 gl, int w, int h) {
          gl.glViewport(0, 0, w, h);
      }
  
      @Override
      public void onDrawFrame(GL10 gl) {
          // define the color we want to be displayed as the "clipping wall"
          gl.glClearColor(_red, _green, _blue, 1.0f);
          // clear the color buffer to show the ClearColor we called above...
          gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
      }
  
      public void setColor(float r, float g, float b) {
  
          _red = sw.getRed();     // Want these to grab the values from my onCreate method
          _green = sw.getGreen(); // But instead it's getting the nul values
          _blue = sw.getBlue();   // eg values as set above me onCreate.
  
  //        _red = r;
  //        _green = g;
  //        _blue = b;
  
      }
  }
  </code></pre>
  
  <p><em><strong></em> VortexView.java**</strong></p>
  
  <pre><code>package com.clockworkrobot.vortex;
  
  import android.content.Context;
  import android.opengl.GLSurfaceView;
  import android.view.MotionEvent;
  
  public class VortexView extends GLSurfaceView {
      private static final String LOG_TAG = VortexView.class.getSimpleName();
      private VortexRenderer _renderer;
  
      public VortexView(Context context) {
          super(context);
          _renderer = new VortexRenderer();
          setRenderer(_renderer);
      }
  
      public boolean onTouchEvent(final MotionEvent event) {
          queueEvent(new Runnable() {
              public void run() {
                  _renderer.setColor(event.getX() / getWidth(), event.getY() / getHeight(), 1.0f);
              }
          });
          return true;
      }
  }
  </code></pre>
  
  <p><em><strong></em> AndroidManifest.xml**</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.clockworkrobot.vortex"
        android:versionCode="1"
        android:versionName="1.0"&gt;
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
          &lt;activity android:name=".Vortex"
                    android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
      &lt;uses-sdk android:minSdkVersion="3" /&gt;
  &lt;/manifest&gt; 
  </code></pre>
  
  <p>In essence.. What I require is a way to save and recover the current screen colour when the game opens and closes. 
  Thanks to everyone who has helped so far.</p>