Hi,
Is it possible to stop my application from closing when the home button is pressed using B4A? and if so does it matter if it is a physical home button? the reason is i am building and educational app for my 2 yr old and would like to be able to stop him from accidentally exiting the app and consequently accessing other areas of my phone. I have added another way of exiting the application by long clicking on a button on the home screen which makes visible a quit button
I have had a search and found how to trap the back button from exiting but it does not work for my home button.
Also I use this code to switch between layouts using the 1 activity. Is there a better way to write this code as it seems very slow the further i progress through the layouts. Maybe using a for each loop? if so how would i write it?
I did try using the sliding panels code but could not get it to work using layouts.
this is the button event
this sets the layout dependant on the counterpage value
any help appreciated thnx
Is it possible to stop my application from closing when the home button is pressed using B4A? and if so does it matter if it is a physical home button? the reason is i am building and educational app for my 2 yr old and would like to be able to stop him from accidentally exiting the app and consequently accessing other areas of my phone. I have added another way of exiting the application by long clicking on a button on the home screen which makes visible a quit button
I have had a search and found how to trap the back button from exiting but it does not work for my home button.
Also I use this code to switch between layouts using the 1 activity. Is there a better way to write this code as it seems very slow the further i progress through the layouts. Maybe using a for each loop? if so how would i write it?
I did try using the sliding panels code but could not get it to work using layouts.
this is the button event
B4X:
Dim counter As Int
Dim counterpage As Int
B4X:
Sub Button2_Click
counterpage = counter + 1
counteraspage
counter = counterpage
End Sub
Sub Button1_Click
counterpage = counter - 1
counteraspage
counter = counterpage
End Sub
this sets the layout dependant on the counterpage value
B4X:
Sub counteraspage
If counterpage = 0 Then
Activity.LoadLayout("A")
End If
If counterpage = 1 Then
Activity.LoadLayout("B")
End If
If counterpage = 2 Then
Activity.LoadLayout("C")
End If
If counterpage = 3 Then
Activity.LoadLayout("D")
End If
If counterpage = 4 Then
Activity.LoadLayout("E")
End If
If counterpage = 5 Then
Activity.LoadLayout("F")
End If
If counterpage = 6 Then
Activity.LoadLayout("G")
End If
If counterpage = 7 Then
Activity.LoadLayout("H")
End If
If counterpage = 8 Then
Activity.LoadLayout("I")
End If
If counterpage = 9 Then
Activity.LoadLayout("J")
End If
If counterpage = 10 Then
Activity.LoadLayout("K")
End If
If counterpage = 11 Then
Activity.LoadLayout("L")
End If
If counterpage = 12 Then
Activity.LoadLayout("M")
End If
If counterpage = 13 Then
Activity.LoadLayout("N")
End If
If counterpage = 14 Then
Activity.LoadLayout("O")
End If
If counterpage = 15 Then
Activity.LoadLayout("P")
End If
If counterpage = 16 Then
Activity.LoadLayout("Q")
End If
If counterpage = 17 Then
Activity.LoadLayout("R")
End If
If counterpage = 18 Then
Activity.LoadLayout("S")
End If
If counterpage = 19 Then
Activity.LoadLayout("T")
End If
If counterpage = 20 Then
Activity.LoadLayout("U")
End If
If counterpage = 21 Then
Activity.LoadLayout("V")
End If
If counterpage = 22 Then
Activity.LoadLayout("W")
End If
If counterpage = 23 Then
Activity.LoadLayout("X")
End If
If counterpage = 24 Then
Activity.LoadLayout("Y")
End If
If counterpage = 25 Then
Activity.LoadLayout("Z")
End If
If counterpage > 25 Then
Activity.LoadLayout("A")
counterpage = 0
counter = 0
End If
End Sub
any help appreciated thnx