@Override
 protected void onDestroy() {
   inactivityTimer.shutdown();
   super.onDestroy();
   offLight();
   OttoAppConfig.getInstance().unregister(this);
 }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    OttoAppConfig.getInstance().register(this);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);
    //        requestWindowFeature(Window.FEATURE_NO_TITLE);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (LinearLayout) findViewById(R.id.capture_container);
    scanCropView = (LinearLayout) findViewById(R.id.capture_crop_view);
    ImageView scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation =
        new TranslateAnimation(
            Animation.RELATIVE_TO_PARENT,
            0.0f,
            Animation.RELATIVE_TO_PARENT,
            0.0f,
            Animation.RELATIVE_TO_PARENT,
            0.0f,
            Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(2000);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);

    initButton();
  }