help with code

twisted

Member
Licensed User
Longtime User
:sign0104:is there a way to run my app during slideout of keyboard and minimize it when slide-in of keyboard?
can you help me with the code? i'm a noob at coding and stuff.
thanks in advance.

btw. i'm using a ppc with slide-out keyboard.
 

twisted

Member
Licensed User
Longtime User
It is possible to catch the display orientation change event with agraham's SystemState library.
You will need to set an event for 'DisplayRotation' property.

hi,
how or what is the code to create/set an event for display rotation property?
i don't know how to code this, i have not done any coding.
thanks for the help.

regards,
mike
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this code (file is attached):
B4X:
Sub Globals

End Sub

Sub App_Start
    Form1.Show
    flb.New1("form1",B4PObject(1))
    SysState.New1("DisplayRotation")
End Sub

Sub SysState_StateChanged 'This code will be fired when the orientation will chage.
    form1.Show
    textbox1.Text = SysState.CurrentValue 'will return 90 or 0 depending or the orientation.
End Sub

Sub Menu1_Click
    AppClose
End Sub
You will need to download the SystemState library.
 

Attachments

  • SystemStateDemo.sbp
    735 bytes · Views: 163

twisted

Member
Licensed User
Longtime User
thanks for the reply but i dont know how to implement the code into my app.
what i want to do is to run my app during slide out of keyboard and run in background when slide in of keyboard.

B4X:
Sub App_Start

   flb.New1("landscape",B4PObject(1))
   sysstate.New1("DisplayRotation")
End Sub

Sub SysState_StateChange

   landscape.Show 'landscape is the name of the form
   If (SysState.CurrentValue=270) Then landscape.Show 'run the form when landscape mode
   If (SysState.CurrentValue=0) Then hardware.ShowTodayScreen 'run my app in background
End Sub

is it possible with the code above?
thanks again.
 

twisted

Member
Licensed User
Longtime User
Exactly, except of the first line: lansdcape.show.

hi there again,
i can't seem to get it working, i have attached the source code of my app, can you take a look if you have time. thanks very much.
 

twisted

Member
Licensed User
Longtime User
Please try to change the sub to:
B4X:
Sub SysState_StateChange
    If SysState.CurrentValue=0 Then hardware.ShowTodayScreen
    If SysState.CurrentValue=270 OR sysstate.currentValye = 90 Then Landscape.Show
End Sub

BTW, you should only upload source code and other image files. No need to upload dlls.

hi there again,
i still can't get it to work, so i made a new app (say app1) to run another app (say app2). that way i can get it to work when i slide my keyboard out and i made an event for app1 to kill the process of app2 when i slide the keyboard in.

the problem is when i slide the keyboard out again it takes a while to load/open app2.

is there a way to run and minimize or hide app2 by running app1 so that when i slide the keyboard in & out it will load fast? is there a way to combine the two apps? and is there a way to lessen the memory consumption of the apps?
thanks again and sorry for all the trouble.
attached are the source codes

regards,
mike
 

Attachments

  • RUN.SBP
    903 bytes · Views: 158

Erel

B4X founder
Staff member
Licensed User
Longtime User
Apparently the system changed event is not accurate enough.
Another solution would be to use a timer to test its value:
B4X:
Sub Globals
    lastOrientation = -1
End Sub

Sub App_Start
    Form1.Show
    flb.New1("form1",B4PObject(1))
    SysState.New1("DisplayRotation")
    hardware.New1
    textbox1.Text = sysstate.CurrentValue
    Timer1.Interval = 100
    Timer1.Enabled = True
End Sub

Sub Timer1_Tick
    newOrientation = SysState.CurrentValue
    If newOrientation = lastOrientation Then Return
    
    If newOrientation = 0 Then hardware.ShowTodayScreen
    If SysState.CurrentValue=270 OR SysState.CurrentValue=90 Then form1.Show
    lastOrientation = newOrientation
End Sub
 

twisted

Member
Licensed User
Longtime User
still not working for me, anyway thanks for the help, maybe i need to do some research & study some programming language first before i make some app, hehe.

regards,
mike

p.s.
is there a way to hide application1 by running application2? thanks.
 
Top