How can I set Activity.Background as the current wallpaper in B4A?
Activity.Background = ???
Thank you!
JAVA CODE
B4X:
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
Main.this.getWindow().setBackgroundDrawable(wallpaperDrawable);
=======================
I have got it! Thank everyone!
B4X:
Dim r As Reflector
Dim b As Bitmap
Dim d As BitmapDrawable
b.InitializeMutable(Activity.Width,Activity.Height)
d.Initialize(b)
r.Target = r.RunStaticMethod("android.app.WallpaperManager", "getInstance", Array As Object(r.GetContext), Array As String("android.content.Context"))
Activity.Background = r.RunMethod("getDrawable")
There is an example of drawing a bitmap. If you want to draw an activity to the live wallpaper you will need to first save the activity background as a bitmap.
You can create a new bitmap and draw the activity background with Canvas.DrawDrawable.
There is an example of drawing a bitmap. If you want to draw an activity to the live wallpaper you will need to first save the activity background as a bitmap.
You can create a new bitmap and draw the activity background with Canvas.DrawDrawable.
There is an example of drawing a bitmap. If you want to draw an activity to the live wallpaper you will need to first save the activity background as a bitmap.
You can create a new bitmap and draw the activity background with Canvas.DrawDrawable.
Sub SetWallPaper(Bmp 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(Bmp), Array As String("android.graphics.Bitmap"))
ToastMessageShow("Wallpaper added successfully.",False)
End Sub
Without knowing what part of that screen shot is in your app and what part is the device's wallpaper, I can't tell what your screen shot is showing.
The screen shot in your other message doesn't appear to be a full screen, so it can't be the device's wallpaper, so I still can't tell what it is you want.
Sorry.
----Edit:
Now that you have posted the full screen shot, it appears that your problem with the screen shot in the other post is that you are not getting the transparent background when you enter Activity.Color = Colors.Transparent. Did you change the manifest file following the directions in this post?
If you did follow all the directions and still can't get it to work, then I'm afraid I'm not the one who can help you.
Now that you have posted the full screen shot, it appears that your problem with the screen shot in the other post is that you are not getting the transparent background when you enter Activity.Color = Colors.Transparent. Did you change the manifest file following the directions in this post?
If you did follow all the directions and still can't get it to work, then I'm afraid I'm not the one who can help you.
Sub SetWallPaper(Bmp 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(Bmp), Array As String("android.graphics.Bitmap"))
ToastMessageShow("Wallpaper added successfully.",False)
End Sub
Dim r As Reflector
Dim b As Bitmap
Dim d As BitmapDrawable
b.InitializeMutable(Activity.Width,Activity.Height)
d.Initialize(b)
r.Target = r.RunStaticMethod("android.app.WallpaperManager", "getInstance", Array As Object(r.GetContext), Array As String("android.content.Context"))
Activity.Background = r.RunMethod("getDrawable")