Android Question Start activity from starter module?

MarianoD

Member
Licensed User
Longtime User
Hello, please apologizemy english, i am new in this.

I am using GPS sample, and works great!

Now i want to show an "accept my conditions" screen, at the very begining of my app, with a check box and a button... I made it. My question is, can i start this screen from inside the starter module (the one with gps stuffs)?

I suposed i cant, so i put this at the beginin of my main activity:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If File.Exists(File.DirInternal  & "/AAA", "")=False Then File.MakeDir(File.DirInternal , "AAA")
    If File.Exists(File.DirInternal & "/AAA", "ACECON.TXT")=False Then
            StartActivity(frmCondiciones)
            If File.Exists(File.DirInternal & "/AAA", "ACECON.TXT")=False Then ExitApplication
    End If

The frmCondiciones screen, make the TXT file if you check the checkbox.
The problem is, after check box and press button, IT SENDS ME TO A GOOGLE SCREEN!! I believe is Google Now screen... showa 1 second and then the app ends.

What is happeninng? Should i start frmCondiciones from starter module?
Thanks!!
 
Last edited:

MarianoD

Member
Licensed User
Longtime User
Sorry, my english is not good and i cant explain my problem...

STARTER MODULE, GPS STUFFS

MAIN ACTIVITY
B4X:
Sub Activity_Create(FirstTime As Boolean)
  ...
  ...
  If File.Exists(File.DirInternal & "/AAA", "ACECON.TXT")=False Then StartActivity(frmCondiciones)
End Sub

"ACCEPT CONDITIONS" ACTIVITY (named frmCondiciones)
B4X:
Sub cmdCon_Click
    File.WriteString (File.DirInternal & "/AAA", "ACECON.TXT","SOME TEXT")
    Activity.Finish
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Select KeyCode
        Case KeyCodes.KEYCODE_BACK
            CallSubDelayed(Me, "HandleBackKey")
            Return True
    End Select
    Return False
End Sub

Sub HandleBackKey
    ExitApplication
End Sub

Why when i press back on the "accept conditions" screen, the app does not exit? It keeps showing "accept conditions" screen again and again and again... in a loop. Thanks.
 
Last edited:
Upvote 0

MarianoD

Member
Licensed User
Longtime User
Updated

The loops still continues, even using (i read exitapplication is not good):

B4X:
Sub HandleBackKey
    Starter.GPS1.Stop
    StopService(Starter)
    Activity.Finish
    ExitApplication
End Sub

The application does not exit.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

MarianoD

Member
Licensed User
Longtime User
DonManfred, i started writing a pseudo-code, because of that i did not use code tag, then paste some real code and forget use tag, sorry man.
Thanks for your help.
 
Upvote 0

MarianoD

Member
Licensed User
Longtime User
Thanks all for help.

I solved using JordiCP post (thanks!!!!), with something like this on Main activity, and secondary activity put want2exit=true if back is pressed on "accept conditions screen", and added gps stop and exitapplication because with only activity.finish app dont close:

B4X:
Sub Activity_Resume
    if want2exit=True then
        Starter.GPS1.Stop
        Activity.Finish
        ExitApplication
    else
        ....
    endif
End Sub
 
Upvote 0
Top