title: android.content.Context vs android.app.Activity
body: <p>I want to pass a reference of the current activity to a method of a class not extending Activity. I need to use this reference to the active activity so that I can use <code>getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);</code></p>
  
  <p>I pass both the current context and activity to the class object using these setter methods in the class:</p>
  
  <pre><code>public class VersionCheck {
  
      public Context context;
      public Activity activity;
  
      //---------------------------------------------------------------------------------------------------------
      //set the current context
      //---------------------------------------------------------------------------------------------------------
      public void setContext(Context context) {
  
          this.context = context;
      }
  
      //---------------------------------------------------------------------------------------------------------
      //set the current activity
      //---------------------------------------------------------------------------------------------------------
      public void setActivity(Activity activity) {
  
          this.activity = activity;
      }   
  </code></pre>
  
  <p>The reference to the activity is used in an AsyncTask in the class (extract below):</p>
  
  <pre><code>//---------------------------------------------------------------------------------------------------------
  //asynchronous task to check if there is a newer version of the app available
  //---------------------------------------------------------------------------------------------------------
  private class UpdateCheckTask extends AsyncTask&lt;String, Void, String&gt; {
  
  HttpClient httpclient;
  HttpPost httppost;
  HttpResponse response;
  InputStream inputStream;
  byte[] data;
  StringBuffer buffer;
  
  protected void onPreExecute ()
  {
      VersionCheck vc = new VersionCheck();
  
      //do not lock screen or drop connection to server on login
          activity.getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
  
          //initiate progress dialogue to block user input during initial data retrieval
          ProcessingDialog = ProgressDialog.show(context, "Please Wait", "Checking for Updates", true,false);
  }
  
      @Override
      protected String doInBackground(String... currentVersion) 
      {
  </code></pre>
  
  <p>How do I get a reference to the Activity so that I can pass it to the setActivity(Activity) method? I use myActivity.this as reference for the context. Is it the same for Activity?</p>