Android Question EMAIL Program Flow

Startup

Active Member
Licensed User
Longtime User
I'm having a problem getting code to run after sending an email (see code below) which illustrates the problem.
The code after the line -- StartActivity(emsg.GetIntent) -- gets ignored -- so the MsgSentCk sub does not get run. It appears that after the email is sent (user presses send) the program resumes in the Main Activity ignoring the -- MsgSentCk -- code line. Is there anyway to get program flow to include code lines after sending an email?
B4X:
Sub SendEmail
    Dim msg As String
    msg="ok"
    email="test@test.com"
    Dim emsg As Email
    emsg.To.Add(email)
    emsg.Subject=msg
    emsg.Body=msg
    StartActivity(emsg.GetIntent)
    MsgSentCk
End Sub

Sub MsgSentCk
    Msgbox("msg","sent")
End Sub
 

Startup

Active Member
Licensed User
Longtime User
I've modified (code in red) to continue the program flow in Resume.
OK? Or is there a better way to do this? Thanks!

B4X:
Sub Activity_Resume
    If emailsentck="yes" Then MsgSentCk
End Sub

Sub SendEmail
    Dim msg As String
    msg="ok"
    email="test@test.com"
    Dim emsg As Email
    emsg.To.Add(email)
    emsg.Subject=msg
    emsg.Body=msg
    StartActivity(emsg.GetIntent)
    emailsentck="yes
End Sub

Sub MsgSentCk
    Msgbox("msg","sent")
    emailsentck=""
End Sub
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You are member since 3 Years and have posted more than 100 Posts.

You should know you need to use code tags when posting code!
 
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
Hi...

I figure that you "skip" Erel comment:

The code is executed however you cannot show a msgbox after calling StartActivity. Use Log instead and you will see that the code is executed immediately. This is not what you are looking for.

You need to continue the program flow in Activity_Resume.

Regards,

Edgar
 
Upvote 0
Top