Thanks Erel this works perfectly for the ball wallpaper example as well as the smiley example, the only change that has to be made for the smiley (libgdx live wallpaper) is:
'("package name", "service name as written in manifest")
Array As Object("com.mycomp.LWP", "anywheresoftware.b4a.libgdx.lgLiveWallpaper")
'the service name for Libgdx live wallpaper is different...
So for my button I send the user to my wallpaper if the user is running jellybean or above, and to the live wallpaper chooser if he is running older versions of android, so the code looks as follows:
Dim r As Reflector
Dim Intent1 As Intent
Dim Api As Int
Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
If Api < 16 Then
Intent1.Initialize("android.service.wallpaper.LIVE_WALLPAPER_CHOOSER","")
StartActivity(Intent1)
Else
Intent1.Initialize("android.service.wallpaper.CHANGE_LIVE_WALLPAPER","")
Dim cn As JavaObject
'("package name", "service name as written in manifest")
cn.InitializeNewInstance("android.content.ComponentName", Array As Object("com.mycomp.LWP", "anywheresoftware.b4a.libgdx.lgLiveWallpaper"))
Intent1.PutExtra("android.service.wallpaper.extra.LIVE_WALLPAPER_COMPONENT",cn)
StartActivity(Intent1)
End if
FYI, the code for the wallpaper chooser crashes when I am testing it on an emulator running version 2.3.7, but it works perfectly when I test it on my Samsung galaxy S device (music player) which is running version 2.3.5 (same API 10).
if I change that code to:
Intent1.Initialize("android.intent.action.SET_WALLPAPER", "")
Intent1.SetComponent("com.android.wallpaper.livepicker/.LiveWallpaperActivity")
It works as a chooser/picker code on my version 4.1+ emulator and devices (if running it without the if statement shown above), but crashes on both 2.3 device and emulator.
So to sum it up:
- Chooser/picker code 1 crashes with 2.3 emulator (Error 1 -see snapshot) but works on my device running the same API
- Chooser/picker code 2 crashes with 2.3 emulator and device (Error 2 -see snapshot) but works on my emulators and devices running 4.1+ (I did not test 3.0 or 4.0 - but my guess is 4.0 should be ok - 3.0 devices are uncommon so no need to test)
Again, thanks Erel for all the help, and sorry for this long post. I just thought a detailed post might help someone that runs into this same issue...
View attachment 25098 View attachment 25099