Rewrite starting and stopping of the activity recognition