Wish Full-screen Immersive mode android 4.4

Erel

Administrator
Staff member
Licensed User
Last edited:

appie21

Active Member
Licensed User
Hello

I have add that code

but when I add a imageview and put the folowinng line
ImageView1.SetLayout(0,0,GetDeviceLayoutValues.Width ,GetDeviceLayoutValues.Height)

there will be a gray place(where normaly the back and home buttons are) and the imageview will not be gone full screen

also if I ask sthe values of my screen they will give not the resolution of the real screen size but always the space area

for example my tablet have a resolution of 1920 by 1200
then GetDeviceLayoutValues.Height = 1104

what do I wrong or is it a bug?
 

Informatix

Expert
Licensed User
If you don't change the orientation, 100%x and 100%y return the right values. If you change the orientation, they are wrong but it's not the only problem. Click on the volume button; the status bar remains visible. You can set the visibility listener to handle this case:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim jo As JavaObject = Activity
   Dim e As Object = jo.CreateEvent("android.view.View.OnSystemUiVisibilityChangeListener", "VisibilityChanged", Null)
   jo.RunMethod("setOnSystemUiVisibilityChangeListener", Array As Object(e))
   Activity.Width = -1
   Activity.Height = -1
End Sub

Sub Activity_Resume
    Activity.Color = Colors.Red
End Sub

Sub ForceImmersiveMode
    Dim r As Reflector
    r.Target = r.GetActivity
    r.Target = r.RunMethod("getWindow")
    r.Target = r.RunMethod("getDecorView")
    r.RunMethod2("setSystemUiVisibility", 5894, "java.lang.int")
End Sub

Sub VisibilityChanged_Event(MethodName As String, Args() As Object) As Object
    ForceImmersiveMode
End Sub

Sub Activity_WindowFocusChanged(HasFocus As Boolean)
    If HasFocus Then
        ForceImmersiveMode
    End If
End Sub
Unfortunately the visibility listener is not always triggered after an orientation change, even if you call ForceImmersiveMode, and I don't know why.
Note that the solution in post #2 crashes because of Activity being Null. That's why my ForceImmersiveMode sub uses r.GetActivity.
 

Douglas Farias

Expert
Licensed User
@Informatix
1° i m trying to use your code of post #8 this works my activity go to 100%x 100%y screen
but i need change all views on the screnn too ?

my panel is 5%x , 95%x later i user your code my activity go to 100%x but my panel stay on the old place dont change the x values


2° its correct use this to see if user have kitkat or no?

B4X:
  Try
  Dim jo As JavaObject = Activity
  Dim e As Object = jo.CreateEvent("android.view.View.OnSystemUiVisibilityChangeListener", "VisibilityChanged", Null)
  jo.RunMethod("setOnSystemUiVisibilityChangeListener", Array As Object(e))
  Activity.Width = -1
  Activity.Height = -1
  Catch
  Log("....")
  End Try
 

Informatix

Expert
Licensed User
but i need change all views on the screnn too ?
Your code (or your layout script) is supposed to adjust the position and size of all views according to the screen size, so call it again (or reload your layout) after setting the mode on.

2° its correct use this to see if user have kitkat or no?
A cleaner way is to read the Android SDK number:
B4X:
    Dim Ph As Phone
    If Ph.SdkVersion >= 19 Then
      Dim jo As JavaObject = Activity
     ....
 

Erel

Administrator
Staff member
Licensed User

appie21

Active Member
Licensed User
this = Full screenmode

And it work also with 4.2.2

But only gray are at the bottom. But Buttons are away
 
Top