Android Question App exit when I clicked a button to go to other Activity

Luis Felipe

Member
Licensed User
Longtime User
Hello everybody,

I got 2 activities and I pass from 1 to another with a button.
But when I clicked it the app exit.
I can't see the log because I debug the app directly on the Tablet and it's not USB debugging compatible :-(.
The code stops here:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
        SQL1.Close        'if the user closes the program we close the database
    End If
End Sub
I haven't change nothing to the code (related to the sqlite db) modified by Klaus...

Thanx in advance.
 

Attachments

  • SurveyTravel9.zip
    21.3 KB · Views: 99

Luis Felipe

Member
Licensed User
Longtime User
Well I thought I had declared a global variable in the Main module.
Then I test if I kept a value in it after I clicked the Validate button.
If it's the case I pass it to the edittext field in my second screen in order to have one field already filled.
Where am I wrong ?
That part is working now. I got to see how to clear my global variables when needed. I keep testing...
Thanx.
True is only for checking the Boolean ?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Set a BreakPoint in line 140 If Main.gCodigoBus = True Then .
When you run the program it will stop executing at this line.
Then, with
upload_2014-11-6_16-44-38.png
go the next step and look what happens and think why, especially when you come back and Main.gCodigoBus <> "".
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
Hi Klaus. Thank you for your patience.
I don't get it. Testing what you said, I can see that the condition is not true so the code between If and End If is not executed.
I tried with Main.gCodigoBus <> "" but it's quite the same. Moreover when I start the app it goes automatically to the second screen (which is not what is planned!).
May be I'm stupid (but for sure with much less experience that you...)
 

Attachments

  • EncuestaViajerosVAlpha.zip
    23.7 KB · Views: 130
Upvote 0

klaus

Expert
Licensed User
Longtime User
I tried with Main.gCodigoBus <> "" but it's quite the same.
Why do you check if Main.gCodigoBus <> "" ?
Set simply edtCodigoBus.Text = Main.gCodigoBus without the test.
If Main.gCodigoBus = "" edtCodigoBus.Text will be empty.
If Main.gCodigoBus <> "" edtCodigoBus.Text will contain the variable.
Moreover when I start the app it goes automatically to the second screen (which is not what is planned!).
Put a Breakpoint in line 39 If FirstTime Then.
Go step by step through the code and watch the evolution of the variables, you will find why the program goes directly to the second Activity.
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
Why do you check if Main.gCodigoBus <> "" ?
Set simply edtCodigoBus.Text = Main.gCodigoBus without the test.
If Main.gCodigoBus = "" edtCodigoBus.Text will be empty.
If Main.gCodigoBus <> "" edtCodigoBus.Text will contain the variable.

Put a Breakpoint in line 39 If FirstTime Then.
Go step by step through the code and watch the evolution of the variables, you will find why the program goes directly to the second Activity.
When I read it, it seems obvious : I don't know why I did not think about it !
Thank you very much Klaus.
I delete the
B4X:
NewSurvey = "S"
in my Activy_Create of the Main Module and things seems to run fine...
B4A is a great software and this forum an unvaluable source of knowledge (and good people) !
 
Upvote 0
Top