Android Question ** Activity (main) Pause event (activity is not paused). **

Kelvinho

New Member
Hi,
I am new to B4A

I make an app with 2 activities,
1. First activity starts, then press a button to start second activity;
after that, app is exit with "pause event(activity is not paused)" when press a back key

2. I open the app again,
First activity starts and app go crash when start Second activity

Error msgs are shown as below
b4xmainpage_initialize (java line: 363)
java.net.BindException: bind failed: EADDRINUSE (Address already in use)
......

3. Open the app again
First activity starts, then app is exit with msg ** Activity (main) Pause, UserClosed = true ** , when press a back key

Situations 1 & 2 are anormal while situation 3 looks good

My codes are shown below
Appreciate if anyone can help or give some hints


*************************************

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("Main") 'first activity
NewCal

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

If (UserClosed) Then

Else
Activity.Finish
End If
End Sub

Sub Activity_KeyPress(KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
Log("backkey***")
Log(NumActivity)
If NumActivity = 0 Then 'if first activity
Return False
Else 'if second activity
NumActivity = 0
Activity.Finish
Return True

End If

Else
Return False
End If

End Sub

Sub Export_Click

NumActivity = 1 'go second activity
Dim pm As B4XPagesManager
pm.Initialize(Activity)

End Sub
 
Top