Package 

Class AndroidLiveWallpaperService

  • All Implemented Interfaces:
    android.content.ComponentCallbacks , android.content.ComponentCallbacks2

    
    public abstract class AndroidLiveWallpaperService
    extends WallpaperService
                        

    An implementation of the Application interface dedicated for android live wallpapers. Derive from this class. In the onCreateApplication method call the initialize method specifying the configuration for the GLSurfaceView. You can also use AndroidWallpaperListener along with ApplicationListener to respond for wallpaper specific events in your app listener: MyAppListener implements ApplicationListener, AndroidWallpaperListener Notice: Following methods are not called for live wallpapers: pausedispose TODO add callbacks to AndroidWallpaperListener allowing to notify app listener about changed visibility state of live wallpaper but called from main thread, not from GL thread: for example: AndroidWallpaperListener.visibilityChanged(boolean) //obsoleted: //Notice! //You have to kill all not daemon threads you created in pause method. // dispose is never called! //If you leave live non daemon threads, wallpaper service wouldn't be able to close, //this can cause problems with wallpaper lifecycle. Notice #2! On some devices wallpaper service is not killed immediately after exiting from preview. Service object is destroyed (onDestroy called) but process on which it runs remains alive. When user comes back to wallpaper preview, new wallpaper service object is created, but in the same process. It is important if you plan to use static variables / objects - they will be shared between living instances of wallpaper services'! And depending on your implementation - it can cause problems you were not prepared to.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class AndroidLiveWallpaperService.AndroidWallpaperEngine

      Bridge between surface on which wallpaper is rendered and the wallpaper service. The problem is that there can be a groupof Engines at one time and we must share libGDX application between them.

    • Method Summary

      Modifier and Type Method Description
      void onCreate() Service is starting, libGDX application is shutdown now
      WallpaperService.Engine onCreateEngine() One of wallpaper engines is starting.
      void onCreateApplication() libGDX application is starting, it occurs after first wallpaper engine had started.
      void initialize(ApplicationListener listener) Look at initialize
      void initialize(ApplicationListener listener, AndroidApplicationConfiguration config) This method has to be called in the onCreateApplication method.
      SurfaceHolder getSurfaceHolder() Getter for SurfaceHolder object, surface holder is required to restore gl context in GLSurfaceView
      void onDeepPauseApplication() Called when the last engine is ending its live, it can occur when: 1.
      void onDestroy() Service is dying, and will not be used again.
      AndroidLiveWallpaper getLiveWallpaper()
      WindowManager getWindowManager()
      • Methods inherited from class android.service.wallpaper.WallpaperService

        onBind, onCreate, onCreateEngine, onDestroy
      • Methods inherited from class android.app.Service

        getApplication, getForegroundServiceType, onConfigurationChanged, onLowMemory, onRebind, onStart, onStartCommand, onTaskRemoved, onTimeout, onTrimMemory, onUnbind, startForeground, stopForeground, stopSelf, stopSelfResult
      • Methods inherited from class android.content.ContextWrapper

        bindIsolatedService, bindService, bindServiceAsUser, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingOrSelfUriPermissions, checkCallingPermission, checkCallingUriPermission, checkCallingUriPermissions, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermissions, clearWallpaper, createAttributionContext, createConfigurationContext, createContext, createContextForSplit, createDeviceContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createWindowContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getAttributionSource, getAttributionTag, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDataDir, getDatabasePath, getDeviceId, getDir, getDisplay, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFileStreamPath, getFilesDir, getMainExecutor, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getParams, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, isUiContext, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerComponentCallbacks, registerDeviceIdChangeListener, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeSelfPermissionsOnKill, revokeUriPermission, sendBroadcast, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, startActivities, startActivity, startForegroundService, startInstrumentation, startIntentSender, startService, stopService, unbindService, unregisterComponentCallbacks, unregisterDeviceIdChangeListener, unregisterReceiver, updateServiceGroup
      • Methods inherited from class android.content.Context

        getColor, getColorStateList, getDrawable, getString, getSystemService, getText, obtainStyledAttributes, revokeSelfPermissionOnKill, sendBroadcastWithMultiplePermissions
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AndroidLiveWallpaperService

        AndroidLiveWallpaperService()
    • Method Detail

      • onCreate

         void onCreate()

        Service is starting, libGDX application is shutdown now

      • onCreateApplication

         void onCreateApplication()

        libGDX application is starting, it occurs after first wallpaper engine had started. Override this method an invoke initialize from there.

      • getSurfaceHolder

         SurfaceHolder getSurfaceHolder()

        Getter for SurfaceHolder object, surface holder is required to restore gl context in GLSurfaceView

      • onDeepPauseApplication

         void onDeepPauseApplication()

        Called when the last engine is ending its live, it can occur when: 1. service is dying 2. service is switching from oneengine to another 3. [only my assumption] when wallpaper is not visible and system is going to restore some memory forforeground processing by disposing not used wallpaper engine We can't destroy app there, because: 1. in won't work - glcontext is disposed right now and after app.onDestroy() app would stuck somewhere in gl thread synchronizing code 2. wedon't know if service create more engines, app is shared between them and should stay initialized waiting for new engines

      • onDestroy

         void onDestroy()

        Service is dying, and will not be used again. You have to finish execution off all living threads there or short afterthere, besides the new wallpaper service wouldn't be able to start.