Android Question (Closed) Set Elevation of WallPaper?

anOparator

Active Member
Licensed User
Longtime User
I'm trying to place Label1 above changing wallpapers to confirm that a bunch of unseen images aren't displayed overnight but the only time I see Label1 is after the phone wakes from a long sleep, just before it gets covered by the wallpaper.

Ok, so I managed to make an app that lets me create a List of images for the wallpaper, and changes the wallpaper at set intervals, based on using this:
B4X:
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"))
   Log("    NEXT  img # = " & Starter.imgCount)
   Panel1.Visible = True
'   Panel1.Elevation = 100dip     '   not
   Label3.Text = Starter.imgCount
End Sub
Am currently using a Widget to display the counting of the images but most of the app users are not going to drag the Widget onto the desktop.

How can I set the Elevation of WallPaper so that Label1 is always visible?
I am lost in the:
B4X:
Sub SetElevation(v As View, e As Float)
    Dim jo As JavaObject
    Dim p As Phone
   
    If p.SdkVersion >= 21 Then
        jo = v                                               ' What is v?      
        jo.RunMethod("setElevation", Array As Object(e))
    End If
End Sub
Thanks in advance.
 

anOparator

Active Member
Licensed User
Longtime User
The view given to this sub
Yes, but is the Wallpaper a View? And is it referred to as 'r.Target'?
Would it be
B4X:
Sub SetElevation(r.Target, 0)
    Dim jo As JavaObject
    Dim p As Phone
 
    If p.SdkVersion >= 21 Then
        jo = r.Target
        jo.RunMethod("setElevation", Array As Object(0))
    End If
End Sub
Am just trying to keep Label1 visible above the Wallpaper.
Edit:
or since Panel1 is Label1's parent:
B4X:
 Sub Button1_Click
   SetElevation(Panel1, 10)
End Sub

B4X:
Sub SetElevation(v As View, e As Float)
   Dim jo As JavaObject
   Dim p As Phone  
   If p.SdkVersion >= 21 Then
       jo = v 
       jo.RunMethod("setElevation", Array As Object(e))
   End If
End Sub
this did not work.
 
Last edited:
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
In Main module which has select images menu
B4X:
Sub Activity_Pause (UserClosed As Boolean)
   Activity.Finish             <<
End Sub
In module2 with Lable1, removed call to clrMe and set background to Transparent.
B4X:
 Sub SetWallPaper(Bmp As Bitmap)
' clrMe   ' removed this line             <<
   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"))
   Label1.Text = Starter.picNmbr  ' img number from lstPicNum
End Sub
B4X:
 Sub clrMe
   Dim jo As JavaObject
   jo.InitializeContext
   jo.RunMethod("moveTaskToBack", Array(True))
   Panel1.Visible = True
End Sub
Removed the Widget, and Panel1 which was parent for Lable1.
It's probably ugly code but it works, and I'll come back to optimize it later.
ps: uggh. Since only 1 activity can be active, now that I see Label1 and the Wallpaper, I can't access onscreen app Widgets until I click the Back icon and that's when Lable1 stops being visible.
 
Last edited:
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
Closed, am posting the question as it should have been posted.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…