Start by Adding in both subs a Log("{subname}"). Do this to see which event fires first as I do not remember. If the Background event fires first then just create a public boolean variable in the page you want (f.e. bSetToBack = False), make it public and set it from the background event to true when the app gets to background. Then:
Private Sub B4XPage_Disappear
If bSetToBack = False Then
'clear textboxes
End if
End Sub
Also in the Appear event set again bSetToBack = False