<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_activity_lifecycle_changed(self, change):
 """ If the app pauses without pausing the barcode scanner the camera can't be reopened. So we must do it here. """

        d = self.declaration
        if d.active:
            if change['value'] == 'paused':
                self.widget.pause(now=True)
            elif change['value'] == 'resumed':
                self.widget.resume()