Cómo convertir un gif en un fondo de pantalla en vivo para su uso en la aplicación para Android

No necesito un papel tapiz de fantasía que se mueve con tu teléfono, me gustaría usar un gif como un fondo de pantalla en movimiento "en vivo". ¿Es esto posible, y si es así, alguien podría explicarme cómo se hace, o señalarme un recurso que demuestre cómo? No he podido encontrar uno hasta ahora.

Vea la demostración de GIFLiveWallpaper mirar hacia fuera en el reps de github

public class GifLiveWallPaper extends WallpaperService { static final String TAG = "LIVE_WALLPAPER"; static final Handler liveHandler = new Handler(); @Override public Engine onCreateEngine() { try { return new WallPaperEngine(); } catch (IOException e) { Log.w(TAG, "Error creating WallPaperEngine", e); stopSelf(); return null; } } class WallPaperEngine extends Engine { private Movie liveMovie; private int duration; private Runnable runnable; float mScaleX; float mScaleY; int mWhen; long mStart; public WallPaperEngine() throws IOException { InputStream is = getResources().openRawResource(R.raw.sam); if (is != null) { try { liveMovie = Movie.decodeStream(is); duration = liveMovie.duration(); } finally { is.close(); } } else { throw new IOException("Unable to open R.raw.hand"); } mWhen = -1; runnable = new Runnable() { public void run() { nyan(); } }; } @Override public void onDestroy() { super.onDestroy(); liveHandler.removeCallbacks(runnable); } @Override public void onVisibilityChanged(boolean visible) { super.onVisibilityChanged(visible); if (visible) { nyan(); } else { liveHandler.removeCallbacks(runnable); } } @Override public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) { super.onSurfaceChanged(holder, format, width, height); mScaleX = width / (1f * liveMovie.width()); mScaleY = height / (1f * liveMovie.height()); nyan(); } @Override public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) { super.onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset); nyan(); } void nyan() { tick(); SurfaceHolder surfaceHolder = getSurfaceHolder(); Canvas canvas = null; try { canvas = surfaceHolder.lockCanvas(); if (canvas != null) { drawGif(canvas); } } finally { if (canvas != null) { surfaceHolder.unlockCanvasAndPost(canvas); } } liveHandler.removeCallbacks(runnable); if (isVisible()) { liveHandler.postDelayed(runnable, 1000L / 25L); } } void tick() { if (mWhen == -1L) { mWhen = 0; mStart = SystemClock.uptimeMillis(); } else { long mDiff = SystemClock.uptimeMillis() - mStart; mWhen = (int) (mDiff % duration); } } void drawGif(Canvas canvas) { canvas.save(); canvas.scale(mScaleX, mScaleY); liveMovie.setTime(mWhen); liveMovie.draw(canvas, 0, 0); canvas.restore(); } } } 
  • VideoView en un fondo de pantalla en vivo?
  • Android: ¿Cómo iniciar la actividad desde el menú de preferencias?
  • Vídeo de Android como fondo de pantalla en vivo
  • ¿Mejor velocidad de cuadro que dibuja los mapas de bits en una lona?
  • ¿Cómo puedo mostrar el fondo de pantalla en vivo del usuario como fondo en mi aplicación?
  • Uso de Google MapView v2 en Live Wallpaper
  • Error 1 libavcodec.so Formato de archivo no reconocido Android GL Live Wallpaper
  • Cómo cargar imágenes como fondo en LibGDx?
  • Tamaño de la miniatura de vista previa del fondo de pantalla en vivo
  • IllegalArgumentException en unlockCanvasAndPost (fondo de pantalla en vivo Android)
  • Establecer Live Wallpaper de forma programática en Dispositivo enraizado Android
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.