Back button behaviour

FMFREAK

Member
Licensed User
Longtime User
I have an Activity where, within that activity I have 2 menu buttons. Help and Over. When I click on one of them I start a new Activity

B4X:
Sub Help_Click
   StartActivity("help")
End Sub
Sub Over_Click
   StartActivity("over")
End Sub

The activity Help has the following code:

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime1 As Boolean)
   Activity.LoadLayout("help")
   Activity.AddMenuItem("Help", "Help")
   Activity.AddMenuItem("Over de app", "Over")
End Sub

Sub Activity_Resume
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   'Activity.LoadLayout("Main")
End Sub
Sub Help_Click
   StartActivity("help")
End Sub
Sub Over_Click
   StartActivity("over")
End Sub

And the Over activity has:

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim Info As Label
End Sub

Sub Activity_Create(FirstTime2 As Boolean)
   Activity.LoadLayout("over")
   Info.Text="Over de app" & CRLF & CRLF & "Deze app is gemaakt door het Lorentz Casimir Lyceum." & CRLF & "Het is getest met de HTC Desire Z en op de AVD software van Google." & CRLF  &CRLF & "Het Lorentz Casimir Lyceum is niet aansprakelijk voor schade die is of dreigt te worden toegebracht en voortvloeit uit of in enig opzicht verband houdt met het gebruik van deze app." & CRLF & "Ook kunnen wij de correcte werking niet garanderen." & CRLF & "De Lorentz Casimir app maakt gebruik van internet, houd er dus rekening mee dat dit, afhankelijk van je internet abonnement, geld kan kosten" 
   Activity.AddMenuItem("Help", "Help")
   Activity.AddMenuItem("Over de app", "Over")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
   'Activity.LoadLayout("Main")
End Sub

Sub Help_Click
   StartActivity("help")
End Sub
Sub Over_Click
   StartActivity("over")
End Sub

When I click on the main activity on the Help button I get the right Activity but when I klik on the back button, the whole program had closed.
Did someone know a solution ?
 

FMFREAK

Member
Licensed User
Longtime User
No I don't see anything else. This is what the log says:

>>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
CheckJNI is ON
--- registering native functions ---
Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=nl.lcl.lorentz/.main }
Shutting down VM
adbd disconnected
Start proc nl.lcl.lorentz for activity nl.lcl.lorentz/.main: pid=350 uid=10039 gids={3003, 1015}
NOTE: attach of thread 'Binder Thread #3' failed
Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@44f80d18 (uid=10039 pid=350)
Client not active, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44f9ec90
Displayed activity nl.lcl.lorentz/.main: 1898 ms (total 1898 ms)
** Activity (main) Create, isFirst = true **
GC_FOR_MALLOC freed 7409 objects / 310344 bytes in 83ms
** Activity (main) Resume **
GC_EXPLICIT freed 897 objects / 49592 bytes in 344ms
No keyboard for id 0
Using default keymap: /system/usr/keychars/qwerty.kcm.bin
Starting activity: Intent { flg=0x20000 cmp=nl.lcl.lorentz/.help }
** Activity (main) Pause, UserClosed = false **
** Activity (help) Create, isFirst = true **
GC_FOR_MALLOC freed 10233 objects / 526904 bytes in 79ms
** Activity (help) Resume **
Displayed activity nl.lcl.lorentz/.help: 1130 ms (total 1130 ms)
No keyboard for id 0
Using default keymap: /system/usr/keychars/qwerty.kcm.bin
** Activity (help) Pause, UserClosed = true **
request time failed: java.net.SocketException: Address family not supported by protocol

It looks like when I click on the Help button it closed the main activity, but I don't have any code to do that as you can see.
 
Last edited:
Upvote 0

FMFREAK

Member
Licensed User
Longtime User
I feel very stupid :BangHead::BangHead::BangHead:
Sometimes it helps when someone else looks to your code :)
 
Upvote 0
Top