Android Tutorial Android Live Wallpaper tutorial

Highwinder

Active Member
Licensed User
Longtime User
I too was considering loading up that horrible eclipse program to do a LWP. I have to say, this library is extremely easy. I can't wait till the program manages all the XML stuff on it's own though.

No kidding, I was thinking that myself as I was whipping up a new live wallpaper app last night. It would be FANTASTIC if B4A managed the manifest file completely (such as when the Live Wallpaper library is added to a project, the proper additional service code would be inserted into the manifest file, a WallpaperService module would be force-prompted, and the wallpaper.xml file would be automatically copied to the right folder and both marked as read-only, etc).

The full management of the manifest file, as close as B4A already is, would be absolutely incredible.

What a selling point that would be (hint hint).

- Highwinder
 

Highwinder

Active Member
Licensed User
Longtime User
Can video clips of any kind me played as live wallpaper?

Can video clips, such as MP4, be played as live wallpaper in any possible way? using B4A?
 

Highwinder

Active Member
Licensed User
Longtime User
Simplicity

Ok, then I'll just keep it simple by producing animation by looping through a set of still images.

But I've been having a problem even doing this (color me stupid on this one).:sign0104:

I must confess, I'm still trying to wrap my head around how to properly load images in a live wallpaper with the new library. It's not the library's fault, I know it works great.

I very much appreciate the examples, but there's not much description or documentation for the code that is in them, and I am having a hard time trying to decipher them, particularly the "image" live wallpaper example, which is not documented or commented very much at all. To be clear, I have read through the tutorial and the library description multiple times, but still have yet to fully understand things as far as image manipulation goes and proper order of events. I'm usually pretty good at this sort of thing, but for the life of me, I'm really embarrassing myself on this one and come groveling to the gurus.

What I'm attempting to do is just cycle some images for animation in a live wallpaper. But the proper order in which to do things and where to place the timer to cycle the images, etc continue to evade me. In a typical app, I have no problem with this, but the live wallpaper I am still struggling with.:BangHead:

My LWP doesn't even need any kind of layout or menu, I just want it to loop through the images I'm including. I'm sure this is ridiculously simple, but for some reason it hasn't "clicked" for me yet.

Erel, you were right - live wallpaper is definitely a ridiculously strange animal.

Can someone point me in the right direction? :sign0163: Once I have this figured out, I plan on posting a really good "How-To", since I know I can't (or won't) be the only one experiencing this issue.

Again, major thanks to Erel for this fantastic library! :sign0098:
 
Last edited:

Highwinder

Active Member
Licensed User
Longtime User
OK

Ok, Erel, I did exactly that. I hate to embarrass myself like this - it ain't gonna be pretty. But I'd be most grateful for any help you have to offer.

- Highwinder
 
Last edited:

ZeroSoft

Member
Licensed User
Longtime User
hi,
i don't know if there is any other way, but to add a description that is displayed at the live wallpaper menu you need to make a folder named "values" in the "Objects/res" folder and add a .xml file with the name "strings".

strings.xml
B4X:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="description">Your description</string>
</resources>

make it read only

and in the wallpaper.xml add android:description="@string/description"

wallpaper.xml

B4X:
<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
  android:thumbnail="@drawable/icon"
android:description="@string/description"
/>

I hope this will help someone.

Best,
ZeroSoft
 

vasper

Member
Licensed User
Longtime User
Is there a way to add settings to the wallpaper in B4A? For example I wish to set a number for snowflakes on a snow wallpaper I have created.

 

vasper

Member
Licensed User
Longtime User
Ok, but how is the preference screen called? I mean a live wallpaper isn't an application I can put a button on.
 

Gigatron

Member
Licensed User
Longtime User
Ok, but how is the preference screen called? I mean a live wallpaper isn't an application I can put a button on.

Ok to call main activity, you must change the wallpaper.xml file, stored on

Objects/res/xml/wallpaper.xml

eg:

<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="@drawable/icon"
android:description="@string/description"
android:settingsActivity="com.gtr.test99.main" <--- this part load the preference of my wallpaper , com.gtr.test is the packagename of the livewallpaper .
/>

After change this don't forget to set this file wallpaper.xml READ ONLY....

Good luck
 

Gigatron

Member
Licensed User
Longtime User
Additional info for your case


On main activity to do number of snow follow this:


eg:
main.b4a
B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim Spinner1 As Spinner
   Dim Button1 as Button  <---- dont forget this button to QUIT the preference Button Text eg: OK or DONE
   End Sub


B4X:
Sub Activity_Create(FirstTime As Boolean)
 
   activity.LoadLayout("lwp")  <--- load menu from designer lwp.bal file
   
   spinner1.AddAll(Array As string("10","20","30","40","50","60","70","100"))
   
End Sub


Sub Button1_Click
   
   activity.Finish  <-- close main activity...
End Sub


B4X:
Sub Spinner1_ItemClick (Position As Int, Value As Object)
   
   File.WriteString(File.DirInternal,"1.txt",spinner1.SelectedItem)
   CallSub(WallpaperService,"numsnowchanged")  <--- informe subactivity wallpaperservice
   ToastMessageShow("Snow number is now... " & value, False)
   
End Sub






Now on WallpaperService ...

B4X:
' subroutine numsnowchanged

Sub numsnowchanged

' Read file saved before to retriev Selected Spinner value.....
'
    
   If File.Exists(File.DirInternal,"1.txt") Then   
   snownum=File.ReadString(File.DirInternal,"1.txt")
   Else
   snownum=30   ' default snow number .....
   End If


End sub

I dont know other way to pass data to wallpaperservice.

Later
 
Last edited:

squaremation

Active Member
Licensed User
Longtime User
Not sure what I've done wrong but I keep getting this error when trying to run on emulator


B4X:
Compiling code.                         0.01
   Using existing AndroidManifest.xml.
(Project - Do Not Overwrite Manifest option is checked)
AndroidManifest-Example.xml file will be created instead.
Generating R file.                      Error
res\xml\AndroidManifest.xml: Invalid file name: must contain only [a-z0-9_.]
res\xml\AndroidManifest.xml: Invalid file name: must contain only [a-z0-9_.]
res\xml\AndroidManifest.xml:34: error: Error: No resource found that matches the given name (at 'resource' with value '@xml/wallpaper').

:sign0104:
 

susu

Well-Known Member
Licensed User
Longtime User
You need to set file "wallpaper.xml" in folder "Objects/res/xml" to read-only before compile project.
 

horizont

New Member
Hi everyone, i am new to the forum.
I'd like to make a live wallpaper based only on a constant image which will show a different text (a quote in this case) every "n" seconds. I would like to design it for tablets.
Is it a good idea to use the first example in the first post and modify it accordingly?

PS: i can't download the example btw :/

PPS: and also this doesnt seem to be java code, what language are you using in your code snippets
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…