diff --git a/activity_contrib.info b/activity_contrib.info
new file mode 100644
index 0000000..df9fef3
--- /dev/null
+++ b/activity_contrib.info
@@ -0,0 +1,8 @@
+; Id: $
+name = Activity Contrib
+description = "Activity integration for various contrib modules."
+core = 7.x
+dependencies[] = activity
+package = Activity
+files[] = activity_contrib_action_handlers.inc
+; @TODO: add unit tests.
\ No newline at end of file
diff --git a/activity_contrib.info.txt b/activity_contrib.info.txt
deleted file mode 100644
index df9fef3..0000000
--- a/activity_contrib.info.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-; Id: $
-name = Activity Contrib
-description = "Activity integration for various contrib modules."
-core = 7.x
-dependencies[] = activity
-package = Activity
-files[] = activity_contrib_action_handlers.inc
-; @TODO: add unit tests.
\ No newline at end of file
diff --git a/activity_contrib.module b/activity_contrib.module
index 1ea8401..2e6b98e 100644
--- a/activity_contrib.module
+++ b/activity_contrib.module
@@ -12,8 +12,9 @@ function flag_activity_api() {
   // Figure out the activity access control realms.
   $flags = flag_get_flags();
   foreach ($flags as $fid => $flag) {
-    $realms["flag_" . $flag->fid] = $flag->title;
+    $realms["flag_" . $flag->fid] = array('name' => $flag->title);
   }
+
   return array(
     'api' => '3.0-alpha1',
     'realms' => $realms,
diff --git a/activity_contrib_action_handlers.inc b/activity_contrib_action_handlers.inc
index 80e31ea..ac63b20 100644
--- a/activity_contrib_action_handlers.inc
+++ b/activity_contrib_action_handlers.inc
@@ -5,6 +5,146 @@
  * @{
  */
 class FlagActivityActionHandler extends ActivityActionHandler {
+  /**
+   * Return the eid field for this Activity.
+   *
+   * @param array $context
+   *   The context argument passed into the action callback.
+   *
+   * @return int
+   */
+  public function determineEid($context) {
+    $flag = $context['flag'];
+    $type = $flag->content_type;
+    switch ($type) {
+      case 'node':
+        $content_id = $context['node']->nid;
+        break;
+      case 'user':
+        $content_id =  $context['user']->uid;
+        break;
+      case 'comment':
+        $content_id =  $context['comment']->cid;
+        break;
+      default:
+        return 0;
+    }
+    // TODO: need to actually get the sid :-/
+    $record = $flag->get_flagging_record($content_id, $GLOBALS['user']->uid, 0);
+    return $record->fcid;
+  }
+
+  /**
+   * Load objects for tokenization.
+   *
+   * @param int $eid
+	 *   The entity identifier for this Activity.
+   *
+   * @return array
+   */
+  public function loadObjects($eid) {
+    // eid is the fcid
+    $record = db_query("SELECT fid, content_type, content_id from {flag_content} where fcid = :fcid", array(':fcid' => $eid))->fetchAssoc();
+    watchdog('flag stuff', print_r($record, TRUE));
+    $flag = flag_get_flag(NULL, $record['fid']);
+    $content_type = $record['content_type'];
+    $loader = $content_type .'_load';
+    $objects[$content_type] = $loader($record['content_id']);
+    $objects['actor'] = user_load($this->determineActor());
+    return $objects;
+  }
+
+  /**
+   * Return option defaults and structure.
+   *
+   * @return array.
+   */
+  public function optionDefinition() {
+    $options = parent::optionDefinition();
+    $options['flags'] = array(
+      '#default_value' => array(),
+    );
+    $options['view_modes'] = array(
+      '#default_value' => array(),
+    );
+    return $options;
+  }
+
+  /**
+   * Display an FAPI form.
+   *
+   * @param &$form
+   *   An FAPI form array.
+   * @param $form_state
+   *   The form_state from FAPI.
+   */
+  public function optionForm(&$form, $form_state) {
+    parent::optionForm($form, $form_state);
+    $flags = array();
+    
+    foreach (flag_get_flags() as $fid => $flag) {
+      $flags[$fid] = check_plain($flag->name);
+    }
+    $form['flags'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Allowed Flags'),
+      '#options' => $flags,
+      '#default_value' => $this->options['flags'],
+    );
+  }
+
+  /**
+   * Determine if the current Action is valid for this object.
+   *
+   * @param $eid
+   *   The entity id for the activity.
+   * @param $actor
+   *   The uid of the actor for this activity.
+   * @param $timestamp
+   *   Unix timestamp when this activity occurred.
+   * @param array $objects
+   *   The collection of objects for this action.
+   * @param mixed $argument1
+   *   The first argument passed to the action callback.
+   * @param mixed $argument2
+   *   The second argument passed to the action callback.
+   *
+   * @return boolean
+   */
+  public function valid($eid, $actor, $timestamp, $objects, $argument1, $argument2) {
+    $flag_check = TRUE;
+    $allowed_flags = array_filter($this->options['flags']);
+    if (!empty($allowed_flags)) {
+      $flag_name = db_query("SELECT flags.name from {flag_content} INNER JOIN {flags} USING(fid) where fcid = :fcid", array(':fcid' => $eid))->fetchField();
+      $flag_check = in_array($flag_name, $allowed_flags);
+    }
+    return parent::valid($eid, $actor, $timestamp, $objects, $argument1, $argument2) && $flag_check;
+  }
+
+  /**
+   * Return an array of message types.
+   */
+  protected function messages() {
+    $messages = parent::messages();
+    $messages['flag'] = array(
+      'title' => 'Flagger',
+      'description' => 'The person who performed the flagging activity',
+    );
+
+    return $messages;
+  }
+
+  /**
+   * List all eids for this handler, used for batch regeneration and backfilling.
+   *
+   * @param int $offset
+   *   The offset for the query.
+   * @param int $limit
+   *   The limit for the query.
+   */
+  public function listEids($offset, $limit) {
+    return array('total' => 0, 'arguments' => array());
+  }
 }
 
 /**
diff --git a/modules/flag.activity.inc b/modules/flag.activity.inc
new file mode 100644
index 0000000..c3f6459
--- /dev/null
+++ b/modules/flag.activity.inc
@@ -0,0 +1,59 @@
+<?php
+// $Id: $
+
+/**
+ * @file
+ * Provides Activity integration for the flag module.
+ */
+/**
+ * Implementation of hook_activity_grants().
+ */
+function flag_activity_grants($activity) {
+  $flags = flag_get_flags();
+  $grants = array();
+  
+  foreach ($flags as $fid => $flag) {
+    // This will also work for comments as those activity records have nids.
+    if ($activity->nid && $flag->content_type == 'node') {
+      $grants['flag_' . $flag->fid] = array($activity->nid);
+    }
+    elseif ($flag->content_type == 'user') {
+      $grants['flag_' . $flag->fid] = array($activity->uid);
+    }
+  }
+  return $grants;
+}
+
+/**
+ * Implementation of hook_activity_access_grants().
+ */
+function flag_activity_access_grants($account) {
+  // Get all the user and node flags.
+  $user_flags = flag_get_user_flags('user', NULL, $account->uid);
+  $node_flags = flag_get_user_flags('node', NULL, $account->uid);
+
+  $flag_grants = array();
+  if (!empty($node_flags)) {
+    foreach ($node_flags as $flagged_objects) {
+      foreach ($flagged_objects as $nid => $flagged) {
+        // Tell activity to grant user $account access to those flagged with
+        // $fid that are $nid.
+        $flag_grants['flag_' . $flagged->fid][] = $nid;
+      }
+    }
+  }
+
+  if (!empty($user_flags)) {
+    foreach ($user_flags as $flagged_objects) {
+      foreach ($flagged_objects as $uid => $flagged) {
+        // Tell Activity to grant user $account access to those flagged with
+        // $fid that are $uid.
+        $flag_grants['flag_' . $flagged->fid][] = $uid;
+      }
+    }
+  }
+
+  return $flag_grants;
+}
+
+
