How to set wallpaper droid without zoom crop?

Prosg

Active Member
Licensed User
Longtime User
Hello
I want to set wallpaper without zoom crop (i want the exact size of my image)

I do this to set a wallpaper :

B4X:
Sub SetWallPaper(myBmp As Bitmap)
    Dim r As Reflector
    r.Target = r.RunStaticMethod("android.app.WallpaperManager", "getInstance", _
        Array As Object(r.GetContext), Array As String("android.content.Context"))
    r.RunMethod4("setBitmap", Array As Object(myBmp), Array As String("android.graphics.Bitmap"))
   r.RunMethod("suggestDesiredDimensions(360,640)") ' HERE IS THE ERROR LINE
End Sub

Sub Button1_Click
 Dim out As OutputStream
 out = File.OpenOutput(File.DirRootExternal, "myPicture.jpg", False)
 bmp.WriteToStream(out,100,"JPEG")
 out.Close
 SetWallPaper(LoadBitmap(File.DirRootExternal, "myPicture.jpg"))
End Sub

r.RunMethod("suggestDesiredDimensions(360,640)") return an error :
LastException java.lang.NoSuchMethodException : suggestDesiredDimension(360,640)

I want to have this width and height

the java code sample is :

WallpaperManager wm = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
wm.setBitmap(bitmap);
wm.suggestDesiredDimensions(w, h);
and remember to add permissions:

<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>

Thx for your help
 
Last edited:

Prosg

Active Member
Licensed User
Longtime User
your code work ^^ but it don't resolve the problem :(

I want to have exact image (fit) without crop or zoom.


thank you so much for your help Erel
 
Upvote 0

Prosg

Active Member
Licensed User
Longtime User
ok i have this reponse :p

n Sun, Dec 19, 2010 at 2:13 PM, Neilz <[email protected]> wrote:
Basically I've spent way too many hours trying to get this to work
programmatically with a screen sized (320 * 480) image. It clearly
isn't practical to set wallpaper with an image of those dimensions...
I'm just going to have to tell my client "No..."!

Yes, right, as we've been saying you are supposed to set the wallpaper to the size that the wallpaper manager tells you it should be, and if you do anything else then the platform will adjust it to be the dimensions it wants.

As has been said a number of times now, if you want to do something where you set the wallpaper to be an image the exact size of the screen and turn off parallax scrolling, you can't do that by just setting a static image, you'd need to make a "live" wallpaper. (Which again as I have already said, for a static image is relatively simple, but more than a couple lines of code.)

--
Dianne Hackborn
Android framework engineer
[email protected]
- afficher le texte des messages précédents -
 
Upvote 0
Top