title: Using outer class variable in async task
body: <p>I am fairly new to using AsyncTask (and Java in general) so I apologize if I this is a noob question.</p>
  
  <p>I am trying to use a class string inside of an async class that is in my main class.  I hope I explained that correctly.</p>
  
  <p>Basically, I need the string <code>url5</code> to be available in my async task.  I tried placing it into the PreExecute but it doesn't recognize it.  I also tried putting it directly into doInBackground.  It's not letting me set the string as public static inside of the class.  It's let me do it outside of the class but it still can't be recognized by the async task.</p>
  
  <p>Don't know what else to try.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class NewHomepage extends Activity {
  
      public static String url = "http://www.mywebsite.com/android/SQL.php?username=";
      public static String usernamefromlogin;
      public static TextView errorchecking; 
      public static JSONArray user = null;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.reshomepage);
          //get data from previous screen
            Intent intent = getIntent();
            getIntent().getExtras();
  
            //convert intent (intent) to string called "usernamefromlogin"         //error checking in log cat to see value of "usernamefromlogin"      
            usernamefromlogin = intent.getExtras().getString("username2");         Log.d("log usernamefromlogin", usernamefromlogin);
  
            //take the string "url" and add string "usernamefromlogin" after it    //error checking in log cat to see value of url5
            String url5 = url.concat(usernamefromlogin);                           Log.d("log url5", url5);
  
          //start asynch task
           class PostTask extends AsyncTask&lt;String, String, String&gt; {
                 @Override
                 protected void onPreExecute() {
                    super.onPreExecute();
  
                 }//end PreExecute
  
                 @Override
                 protected String doInBackground(String... params) {
                  return null;
  
                  // Creating new JSON Parser
                  JSONParser jParser = new JSONParser();
  
                  // Getting JSON from URL
                  JSONObject json = jParser.getJSONFromUrl(url5);
  
                 }//end doInBackground
  
                 protected void onProgressUpdate(String... values) {
                    super.onProgressUpdate(values);
  
                 }//end onProgressUpdate
  
                 @Override
                 protected void onPostExecute(String result) {
                    super.onPostExecute(result);
  
                 }//end onPostExecute
         }//end Async task
  
         //execute the Async task
         PostTask task=new PostTask();
         task.execute();
  
      }
  
      @Override
      public void onBackPressed() {
          // do nothing on back press do nothing
      }
  
  }//end class
  </code></pre>