I need my wallpaper to act differently when in preview mode (the screen with "Settings" and "Set .. "). How do i know when it's drawn there?
Open the video you want to set as a wallpaper in the Gallery app. Tap on the three-dot menu button in the bottom right corner. Select the 'Set as wallpaper' option in the menu. This will bring up two options — 'Lock screen' and 'Call background'.
Live wallpapers are interactive wallpapers that you can use on your Android home screen, and getting them is so easy.
Install the Video Live Wallpaper app on your Android. To download the app, search the Play Store for "Video Live Wallpaper," then tap the option that has a green hill and house. Tap Install to get the app. You can also use your browser to go to the app's page on the Play Store and tap Install.
To set a live wallpaper, you'll first need to get your hands on one. Some Android phones come pre-loaded with live wallpaper. To set one as your wallpaper, go to “Settings -> Display -> Advanced -> Wallpaper -> Live Wallpapers.” Here you'll find pre-installed live wallpaper and the wallpaper you've downloaded.
The isPreview()
method can be called in the onCreate(SurfaceHolder holder)
method of the implemented Engine. Not in the onCreateEngine
method as the prior answer because the method is not ready.
I'll write in addition to represented answers. As the preview and non-preview engine instances could exist simultaneously, you can add two static instances and one local variable of your engine inside your WallpaperService class (sample in Kotlin):
private var engine: OpenGLEngine? = null
private set
//...
companion object {
private var engineInstance: OpenGLEngine? = null
private var previewEngineInstance: OpenGLEngine? = null
//...
}
and use them in overriding functions
override fun onCreate(surfaceHolder: SurfaceHolder?) {
super.onCreate(surfaceHolder)
if (isPreview) {
previewEngineInstance = this@OpenGLEngine
engine = previewEngineInstance
} else {
engineInstance = this@OpenGLEngine
engine = engineInstance
}
//...
}
override fun onDestroy() {
if (isPreview) {
engine = engineInstance
previewEngineInstance = null
} else {
engine = previewEngineInstance
engineInstance = null
}
//...
super.onDestroy()
}
This way you can always get the current engine instance in your WallpaperService and call its isPreview.
Within onCreateEngine()
you can use the isPreview()
method.
Note that onCreateEngine()
is "normally" called twice: once to create an instance for preview, and then again when you actually set the wallpaper.
Details here: http://developer.android.com/reference/android/service/wallpaper/WallpaperService.Engine.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With