Android Question Activity and Back button

ovt001

Member
Licensed User
Hello everybody.
I have a question.
When I start the main activity, I check FirstTime then I start a procedure to read settings from a file (Settings.ini)

B4X:
If FirstTime Then
        If File.Exists(File.DirInternal, "Settings.ini") = False Then
            File.Copy(File.DirAssets, "Settings.ini", File.DirInternal, "Settings.ini")
        End If
        Activity.LoadLayout("Main")
        'Read Settings.ini file
        ReadIniFileIntoMap
    End If

Sub ReadIniFileIntoMap
'Read setting.ini file and fill al Public variable
    SettingsMap1 = File.ReadMap(File.DirInternal, "Settings.ini")
   
    strNameCam1 = SettingsMap1.Get("NameCam1")
    strNameCam2 = SettingsMap1.Get("NameCam2")
End Sub
It work's fine, but if at that point I click on the "Back button" of my phone, AND I start the app again, The Activity is full black and application blocked.
How do I have to manage the closing of Activity?

Same question when I use StartActivity(Layout2) and from Layout2 I click on "Back button"

Thank You
O.
 

udg

Expert
Licensed User
Having "Activity.LoadLayout("Main")" in the FirstTime code section is generally wrong.
In this specific case is the reason why you see a black screen.
Move it before the check.

Note that if you start another activity w/o finishing the current one, when you click on the Back button while in the second activity you'll resume the first one from its Resume.
Watch video tutorial here.
 
Last edited:
Top