com.badlogic.gdx.backends.android
Class AndroidLiveWallpaperService

java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.app.Service
              extended by android.service.wallpaper.WallpaperService
                  extended by com.badlogic.gdx.backends.android.AndroidLiveWallpaperService
All Implemented Interfaces:
android.content.ComponentCallbacks, android.content.ComponentCallbacks2

public abstract class AndroidLiveWallpaperService
extends android.service.wallpaper.WallpaperService

An implementation of the Application interface dedicated for android live wallpapers. Derive from this class. In the onCreateApplication() method call the initialize(ApplicationListener, boolean) 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: ApplicationListener.pause() ApplicationListener.dispose() 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 ApplicationListener.pause() method. //ApplicationListener.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.

Author:
Jaroslaw Wisniewski

Nested Class Summary
 class AndroidLiveWallpaperService.AndroidWallpaperEngine
          Bridge between surface on which wallpaper is rendered and the wallpaper service.
 
Nested classes/interfaces inherited from class android.service.wallpaper.WallpaperService
android.service.wallpaper.WallpaperService.Engine
 
Field Summary
 
Fields inherited from class android.service.wallpaper.WallpaperService
SERVICE_INTERFACE, SERVICE_META_DATA
 
Fields inherited from class android.app.Service
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
 
Constructor Summary
AndroidLiveWallpaperService()
           
 
Method Summary
 AndroidLiveWallpaper getLiveWallpaper()
           
 android.view.SurfaceHolder getSurfaceHolder()
          Getter for SurfaceHolder object, surface holder is required to restore gl context in GLSurfaceView
 android.view.WindowManager getWindowManager()
           
 void initialize(ApplicationListener listener, AndroidApplicationConfiguration config)
          This method has to be called in the onCreateApplication() method.
 void initialize(ApplicationListener listener, boolean useGL2IfAvailable)
          Look at initialize(ApplicationListener, AndroidApplicationConfiguration)}
 void onCreate()
          Service is starting, libGDX application is shutdown now
 void onCreateApplication()
          libGDX application is starting, it occurs after first wallpaper engine had started.
 android.service.wallpaper.WallpaperService.Engine onCreateEngine()
          One of wallpaper engines is starting.
 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.
 
Methods inherited from class android.service.wallpaper.WallpaperService
onBind
 
Methods inherited from class android.app.Service
getApplication, onConfigurationChanged, onLowMemory, onRebind, onStart, onStartCommand, onTaskRemoved, onTrimMemory, onUnbind, startForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
 
Methods inherited from class android.content.ContextWrapper
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidLiveWallpaperService

public AndroidLiveWallpaperService()
Method Detail

onCreate

public void onCreate()
Service is starting, libGDX application is shutdown now

Overrides:
onCreate in class android.service.wallpaper.WallpaperService

onCreateEngine

public android.service.wallpaper.WallpaperService.Engine onCreateEngine()
One of wallpaper engines is starting. Do not override this method, service manages them internally.

Specified by:
onCreateEngine in class android.service.wallpaper.WallpaperService

onCreateApplication

public void onCreateApplication()
libGDX application is starting, it occurs after first wallpaper engine had started. Override this method an invoke initialize(ApplicationListener, AndroidApplicationConfiguration) from there.


initialize

public void initialize(ApplicationListener listener,
                       boolean useGL2IfAvailable)
Look at initialize(ApplicationListener, AndroidApplicationConfiguration)}

Parameters:
listener -
useGL2IfAvailable -

initialize

public void initialize(ApplicationListener listener,
                       AndroidApplicationConfiguration config)
This method has to be called in the onCreateApplication() method. It sets up all the things necessary to get input, render via OpenGL and so on. If config.useGL20 is set the AndroidApplication will try to create an OpenGL ES 2.0 context which can then be used via Graphics.getGL20(). The GL10 and GL11 interfaces should not be used when OpenGL ES 2.0 is enabled. To query whether enabling OpenGL ES 2.0 was successful use the Graphics.isGL20Available() method. You can configure other aspects of the application with the rest of the fields in the AndroidApplicationConfiguration instance.

Parameters:
listener - the ApplicationListener implementing the program logic
config - the AndroidApplicationConfiguration, defining various settings of the application (use accelerometer, etc.). Do not change contents of this object after passing to this method!

getSurfaceHolder

public android.view.SurfaceHolder getSurfaceHolder()
Getter for SurfaceHolder object, surface holder is required to restore gl context in GLSurfaceView


onDeepPauseApplication

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


onDestroy

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

Overrides:
onDestroy in class android.service.wallpaper.WallpaperService

getLiveWallpaper

public AndroidLiveWallpaper getLiveWallpaper()

getWindowManager

public android.view.WindowManager getWindowManager()


Copyright © 2013. All Rights Reserved.