title: Android: "Expression expected" when passing an Activity class
body: <p>I am kind of new to Android programming and Java in general, and I cannot work out what is causing this error; as I understand it this should work. In the code shown below (near the end of the first snippet), the line <code>"ColourOutput.do_output((Activity) com.(name-removed).(app-name-removed).ColourActivity);"</code> is giving the error <code>"Expression expected"</code> on the text <code>"com.(name-removed).(app-name-removed).ColourActivity"</code> in Android Studio 1.1.0.</p>
  
  <p>(This is inside the class <code>"public class ColourActivity extends Activity"</code>.)</p>
  
  <pre><code>        private Camera.PreviewCallback preview_callback = new Camera.PreviewCallback() {
          @Override
          public void onPreviewFrame(byte[] data, Camera camera) {
              int width = mCamera.getParameters().getPreviewSize().width;
              int height = mCamera.getParameters().getPreviewSize().height;
              int raw_pixels[];
              int pixels[];
  
              raw_pixels = new int[width * height];
              pixels = new int[get_sample_width() * get_sample_height()];
              convert_yuv(raw_pixels, data, width, height);
              crop_pixels(raw_pixels, pixels, width, height, (width - get_sample_width()) / 2, (height - get_sample_height()) / 2, get_sample_width(), get_sample_height());
  
              if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("use_mean", true) == true) {
                  ColourOutput.add_colour_to_output(
                          ColourTools.get_mean(
                                  pixels, get_sample_width(), get_sample_height(),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_secondary", true),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_white", true),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_brightness", true),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_secondary", 32),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_dark", 43),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_light", 128),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("quantization_matching_only", true)
                          ),
                          ColourOutput.ColourType.MEAN);
              }
              if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("use_mode", true) == true) {
                  ColourOutput.add_colour_to_output(
                          ColourTools.get_mode(
                                  pixels, get_sample_width(), get_sample_height(),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_secondary", true),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_white", true),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_brightness", true),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_secondary", 32),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_dark", 43),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_light", 128),
                                  PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("quantization_matching_only", true)
                          ),
                          ColourOutput.ColourType.MODE);
              }
              ColourOutput.do_output((Activity) com.(name-removed).(app-name-removed).ColourActivity);
          }
      };
  </code></pre>
  
  <p>Here is the definition of <strong>"ColourOutput.do_output"</strong>:</p>
  
  <pre><code>public class ColourOutput {
      private static boolean output_clear = true;
      private static String output_buffer = "";
  
      public static enum ColourType {
          MEAN,
          MODE
      }
  
      public static void add_colour_to_output(ColourTools.ColourDescription colour, ColourType type) {
          if (output_clear == true) {
              output_buffer = colour.Brightness.toString() + " " + colour.Colour.toString();
          }
          else {
              output_buffer = output_buffer + " " + colour.Brightness.toString() + " " + colour.Colour.toString();
          }
          output_clear = false;
      }
  
      public static void do_output(Activity activity) {
          ((TextView) activity.findViewById(R.id.output_text)).setText(output_buffer);
          output_buffer = "";
          output_clear = true;
      }
  }
  </code></pre>