Android Question Live Wallpaper App?

designer2k2

Member
Licensed User
Longtime User
Hello,
i have a App with Live Wallpaper, but its made with the now outdated and not compiling LiveWallpaper Library (LiveWallpaper Library)
Im now a bit lost on how to continue with this App, there seems to be no alternative in B4A?

So basically, how to make a Live Wallpaper App in 2023 with B4A?

Greetings
 

designer2k2

Member
Licensed User
Longtime User
it gives the following error when starting on a device:
Java:
*** Service (wallpaperservice) Create ***
wallpaperservice_service_create (java line: 358)
java.lang.NoSuchFieldError: No field isService of type Z in class Lanywheresoftware/b4a/BA$SharedProcessBA; or its superclasses (declaration of 'anywheresoftware.b4a.BA$SharedProcessBA' appears in ***
    at anywheresoftware.b4a.objects.WallpaperInternalService$LWManager.Initialize(WallpaperInternalService.java:74)
    at ***.wallpaperservice._service_create(wallpaperservice.java:358)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at ***.wallpaperservice.onCreate(wallpaperservice.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:4150)
    at android.app.ActivityThread.access$2400(ActivityThread.java:273)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2055)
    at android.os.Handler.dispatchMessage(Handler.java:112)
    at android.os.Looper.loop(Looper.java:216)
    at android.app.ActivityThread.main(ActivityThread.java:7625)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

what seems to relate to B4A 12.2 update that also broke a lib here: https://www.b4x.com/android/forum/threads/crash-of-abto-voip-sip-library-on-b4a-12-20.145974/
 
Upvote 0

designer2k2

Member
Licensed User
Longtime User
i went ahead and used Recaf on the original LiveWallpaper jar file, there i removed the check on "isService" and my App works again :D

old:
Old:
        public static void Initialize(String EventName, boolean TouchEventsEnabled, BA ba) {
            if (ba.sharedProcessBA == null || !ba.sharedProcessBA.isService) {
                throw new RuntimeException("LWManager can only be added to a service.");
            }
            acceptTouch = TouchEventsEnabled;
            LWManager.ba = ba;
            eventName = EventName.toLowerCase(BA.cul);
        }

new:
New:
        public static void Initialize(String EventName, boolean TouchEventsEnabled, BA ba) {
            if (ba.sharedProcessBA == null) {
                throw new RuntimeException("LWManager can only be added to a service.");
            }
            acceptTouch = TouchEventsEnabled;
            LWManager.ba = ba;
            eventName = EventName.toLowerCase(BA.cul);
        }


Further i needed to add android:exported="false" to service in manifest for it to work on latest android:
Code:
AddApplicationText(
<!-- ******** Add the internal service declaration - you can change android:label  ******* -->
<service
        android:label="Engine Wallpaper"
        android:exported="false"
        android:name="anywheresoftware.b4a.objects.WallpaperInternalService"
        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" />
</service>
<!-- End of internal service declaration -->
)

Just that this feels wrong to me, or is this a valid method to make the old lib working? :rolleyes:

Also so far i have not spend much time on testing this, but it seems to work on 2 devices here...
 
Upvote 0

eledu62

Member
i went ahead and used Recaf on the original LiveWallpaper jar file, there i removed the check on "isService" and my App works again :D

old:
Old:
        public static void Initialize(String EventName, boolean TouchEventsEnabled, BA ba) {
            if (ba.sharedProcessBA == null || !ba.sharedProcessBA.isService) {
                throw new RuntimeException("LWManager can only be added to a service.");
            }
            acceptTouch = TouchEventsEnabled;
            LWManager.ba = ba;
            eventName = EventName.toLowerCase(BA.cul);
        }

new:
New:
        public static void Initialize(String EventName, boolean TouchEventsEnabled, BA ba) {
            if (ba.sharedProcessBA == null) {
                throw new RuntimeException("LWManager can only be added to a service.");
            }
            acceptTouch = TouchEventsEnabled;
            LWManager.ba = ba;
            eventName = EventName.toLowerCase(BA.cul);
        }


Further i needed to add android:exported="false" to service in manifest for it to work on latest android:
Code:
AddApplicationText(
<!-- ******** Add the internal service declaration - you can change android:label  ******* -->
<service
        android:label="Engine Wallpaper"
        android:exported="false"
        android:name="anywheresoftware.b4a.objects.WallpaperInternalService"
        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" />
</service>
<!-- End of internal service declaration -->
)

Just that this feels wrong to me, or is this a valid method to make the old lib working? :rolleyes:

Also so far i have not spend much time on testing this, but it seems to work on 2 devices here...

Hello. I've tried to regenerate the LiveWallPaper.jar file using Recaf, but I get an error that I can't fix.
B4X:
58        public B4AEngine(LWEngine l) {
59 >     super((WallpaperService)WallpaperInternalService.this);
60        this.all = new Rect(0, 0, 0, 0);
61        this.cw = new CanvasWrapper();
62        this.lw = l;
63        }

59 constructor Engine in class android.service.wallpaper.WallpaperService.Engine cannot be applied to given types;
required: no arguments
found: android.service.weallpaper.WallpaperService
reason; actual and formal argument lists differ in length.

Could you help me? Thank you!!!
 
Upvote 0
Top