Live wallpaper and Godot help

KeenKeen Posts: 4Member

Hi I'm having some trouble getting live wallpapers to work with android. I've gotten as far as getting a blank live wallpaper on android with the following:

AndroidManifest.xml

<activity android:name="org.godotengine.godot.Godot"
     android:label="@string/godot_project_name_string"
     android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
     android:launchMode="singleTask"
     android:screenOrientation="landscape"
     android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize"
     android:resizeableActivity="false"
     tools:ignore="UnusedAttribute">

     <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
</activity>
<service
    android:name="org.godotengine.godot.WallpaperTest"
    android:enabled="true"
    android:label="cube"
    android:permission="android.permission.BIND_WALLPAPER">
    <intent-filter>
        <action android:name="android.service.wallpaper.WallpaperService" />
    </intent-filter>
    
    <meta-data
        android:name="android.service.wallpaper"
        android:resource="@xml/wallpaper"></meta-data>
</service>

You can see here I've added org.godotengine.godot.WallpaperTest as a WallpaperService

and in org.godotengine.godot.WallpaperTest
package org.godotengine.godot;

import android.os.Handler;
import android.service.wallpaper.WallpaperService;
import android.view.SurfaceHolder;

public class WallpaperTest extends WallpaperService {
    @Override
    public Engine onCreateEngine() {
        return new GDEngine();
    }

    public class GDEngine extends Engine {
        private final Handler handler = new Handler();
        private final Runnable runnable = new Runnable() {
            @Override
            public void run() {
                drawFrame();
            }
        };

        public GDEngine() {
            handler.post(runnable);
        }

        @Override
        public void onCreate(SurfaceHolder surfaceHolder) {
            super.onCreate(surfaceHolder);
            setTouchEventsEnabled(true);
        }
        /*
        @Override
        public void onVisibilityChanged(boolean visible) {

            if (visible) {
                handler.post(runnable);
            } else {
                handler.removeCallbacks(runnable);
            }
        }*/

        void drawFrame() {
            System.out.println("Hello World. Does Godot go here?");
        }


        @Override
        public void onSurfaceDestroyed(SurfaceHolder holder) {
            super.onSurfaceDestroyed(holder);
            handler.removeCallbacks(runnable);
        }
    }
}

This creates a blank wallpaper which you can start up and prints out "Hello World. Does Godot go here?" But that's as far as I've gotten. I'm having trouble linking the actual godot game with the Wallpaper service.

So the main question is how do you run the Godot game in the Wallpaper service?

I've been stuck on this for 2 days now so any help would be greatly appreciated.


Tags :

Comments

  • KeenKeen Posts: 4Member
    edited July 8

    Anybody?

    All I need is a way to get Godot to run on a Wallpaper service. At this rate I might just use libgdx for live wallpaper stuff.

  • TwistedTwiglegTwistedTwigleg Posts: 1,721Admin

    I do not have an Android device, nor experience with working with the Android SDK, so I do not know (I didn’t know there even is a wallpaper service prior to this post!).

    Doing a quick Google search, all I can find is this QA question, which doesn’t really help with implementing the wallpaper. I found this StackOverflow post that might be of some minor help?

    Looking around online, you might want to use libgdx anyway for a lower memory footprint and faster loading times. It seems the most common advice when trying to use a game engine for a live wallpaper is to use something lower level instead if you can.

    Hopefully this helps!

  • KeenKeen Posts: 4Member

    Mmm yeah I saw this. I was thinking with the type of live wallpaper stuff I'm going to do, the graphics and power usage will probably be the same since it is opengl and it will be rendering at 60 frames a second. I use a pretty intense livewallpaper on my phone as well. Its pretty smooth and doesnt take too much batteries either.

    Godot is pretty speedy on android as well from what I could tell so I don't mind using godot for live wallpapers especially with the editor capabilities that comes with it.

    The size of libgdx is smaller but with some tweaks (https://github.com/godotengine/godot/issues/18253) I can get the file smaller.

    I tested and got the livewallpaper example working in libgdx in about 10 minutes lol (as opposed to the days I've spent on this for godot =( )

    I think I'll keep to libgdx for live wallpapers and godot for game stuff for now.

  • TwistedTwiglegTwistedTwigleg Posts: 1,721Admin

    The only other thing I can think of, as far as getting Godot to work as a live wallpaper, is open a feature request on the Godot GitHub repository and see what happens.

    I'm glad you were able to get something working for the live wallpaper, even if it is not Godot. :+1:

  • KeenKeen Posts: 4Member

    I still enjoy using godot and am interested to see where the future holds for it. I'm still going to use godot for everything else. I'll open up a feature request and see what I can get.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file