@Override
 public void onSurfaceDestroyed(final SurfaceHolder holder) {
   if (AndroidLiveWallpaperService.DEBUG)
     Log.d(
         AndroidLiveWallpaperService.this.TAG,
         " > onSurfaceDestroyed() " + hashCode() + ", running: " + runningEngines);
   super.onSurfaceDestroyed(holder);
 }
    @Override
    public void onCreate(final SurfaceHolder surfaceHolder) {
      runningEngines++;
      if (AndroidLiveWallpaperService.DEBUG)
        Log.d(TAG, " > onCreate() " + hashCode() + ", running: " + runningEngines);
      super.onCreate(surfaceHolder);

      // wallpaperListener.setIsPreview(this.isPreview());
    }
 @Override
 public void onDestroy() {
   runningEngines--;
   if (AndroidLiveWallpaperService.DEBUG)
     Log.d(
         AndroidLiveWallpaperService.this.TAG,
         " > onDestroy() " + hashCode() + ", running: " + runningEngines);
   view.onDestroy();
   // app.onDestroy();
   super.onDestroy();
 }
    @Override
    public void onVisibilityChanged(final boolean visible) {
      if (AndroidLiveWallpaperService.DEBUG)
        Log.d(
            AndroidLiveWallpaperService.this.TAG,
            " > onVisibilityChanged(" + visible + ") " + hashCode());
      if (visible) {
        onResume();
      } else {
        onPause();
      }

      super.onVisibilityChanged(visible);
    }
 @Override
 public void onSurfaceChanged(
     final SurfaceHolder holder, final int format, final int width, final int height) {
   if (AndroidLiveWallpaperService.DEBUG)
     Log.d(
         AndroidLiveWallpaperService.this.TAG,
         " > onSurfaceChanged() "
             + isPreview()
             + " "
             + hashCode()
             + ", running: "
             + runningEngines);
   super.onSurfaceChanged(holder, format, width, height);
 }
    @Override
    public void onOffsetsChanged(
        final float xOffset,
        final float yOffset,
        final float xOffsetStep,
        final float yOffsetStep,
        final int xPixelOffset,
        final int yPixelOffset) {

      if (AndroidLiveWallpaperService.DEBUG)
        Log.d(
            AndroidLiveWallpaperService.this.TAG,
            " > onOffsetChanged("
                + xOffset
                + " "
                + yOffset
                + " "
                + xOffsetStep
                + " "
                + yOffsetStep
                + " "
                + xPixelOffset
                + " "
                + yPixelOffset
                + ") "
                + hashCode());

      app.postRunnable(
          new Runnable() {
            @Override
            public void run() {
              AndroidLiveWallpaperService.this.offsetChange(
                  listener, xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);
            }
          });
      super.onOffsetsChanged(
          xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);
    }