Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Live Wallpaper in preview mode

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?

like image 737
Misca Avatar asked Mar 30 '11 16:03

Misca


People also ask

How to apply live wallpaper on Lock screen?

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'.

Can you get live wallpapers on Samsung?

Live wallpapers are interactive wallpapers that you can use on your Android home screen, and getting them is so easy.

How do you make a video a live wallpaper?

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.

Can you set live wallpaper on Android?

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.


3 Answers

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.

like image 80
FranMowinckel Avatar answered Sep 23 '22 07:09

FranMowinckel


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.

like image 42
Max Lebedev Avatar answered Sep 24 '22 07:09

Max Lebedev


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

like image 25
George Freeman Avatar answered Sep 22 '22 07:09

George Freeman