Someone here already did the settings from the live wallpaper to set another background? Example choose another fund in the same screen live wallpaper. If someone already got would post the code? I'm trying to make here is this more difficult! Thank you!
First update the shared prefs xml file to add a list preference. Then extract that preference to a string in the OnSharedPreferenceChanged method of the main java file. Then using a loop statement change the background resource in the getWallpaperResource method. Like this - XML file: Code (text): <ListPreference android:defaultValue="@string/background" android:entries="@array/backgroundNames" android:entryValues="@array/backgroundValues" //values are Background 1, Background 2 android:key="background_settings" android:summary="Change the background" android:title="Choose Background" /> Main Java File: In the OnSharedPreference method- Code (text): selectedBackground = prefs.getString("background_settings", "Background 1"); mBackground = getWallpaperResource(); then in the getWallpaperResource() use a loop statement like: Code (text): if(selectedBackground.equals("Background1")) { bg = BitmapFactory.decodeResource(getResources(), R.drawable.backgroundimage);}
Hi James. I tried to implement here, plus I'm not getting this giving error .. Could be made available for download an example of a project by choosing various background? Or at least the java files to the methods implemented .. Thank you for your help!
Hello James! James are various errors, like much possible if you put up here in the forum with a link to download an example ... I would be eternally grateful! So missing this for my live wallpaper stay good! I hope your help! Thank you for your attention and help here in the forum!
Below is a link to a demo project created for changing the background https://drive.google.com/folderview?id=0Bw1eCPuQRC7JcEt6UE5MN2xWN0U&usp=sharing
Perfect James! Wow, thanks a lot for example, and for helping me! You helped me a lot with this example! You here in the forum Live Wallpaper Creator are really cool! I greatly appreciate the help James! Success for you! Thank you, Thank you, Thank you = D.
Does somebody know how to include this into the source code generated by LWC 2.6? The main class is guite different. I tried it, but I still have some errors wich I cant solve.
Instead of using this from 2.1 Code (text): if(selectedBackground.equals("Background1")) { bg = BitmapFactory.decodeResource(getResources(), R.drawable.backgroundimage);} try this in 2.6 Code (text): if (selectedBackground.equals("Background 1")) { res = R.drawable.wallpaper_hdpi; if (sfHigh > sfMid) { // use mid resolution image scaleFactor = sfMid; res = R.drawable.wallpaper_mdpi; } } else if (selectedBackground.equals("Background 2")) { res = R.drawable.wallpaper2_hdpi; if (sfHigh > sfMid) { // use mid resolution image scaleFactor = sfMid; res = R.drawable.wallpaper2_mdpi; } } else { res = R.drawable.wallpaper3_hdpi; if (sfHigh > sfMid) { // use mid resolution image scaleFactor = sfMid; res = R.drawable.wallpaper3_mdpi; } } EDIT: Also comment this code in init() method Code (text): if (background == null) background = getWallpaperResource();
Hello James, I followed the steps mentioned above however I am not sure what is to be done in the main Java file as I am quite new to eclipse, I am using LWC 2.6. I will be grateful if you could help me with the option to choose backgrounds. The link to the Demo Project is empty. Thanks
You can check the link again. I have reuploaded it.The demo project is from LWC 2.1. Just follow the steps mentioned above for LWC 2.6 Will try and create a demo project for 2.6
Hello, James I've tried it on 2.6 but it giving error on XML, can you please help me for this?? Please.