Android Question App fails to rerun properly after Intent

JohnC

Expert
Licensed User
Hi,

Below is simple code to send a text message by an Intent to send it using the device's built-in SMS app:

B4X:
Sub SendText(Telnum as String, Mess as String)

    Dim iIntent As Intent    'for sms sending

    iIntent.Initialize("android.intent.action.SEND", "")       
    iIntent.PutExtra("address", TelNum)
    iIntent.PutExtra("sms_body", Mess)

    StartActivity(iIntent)   
       
    ExitApp
       
End Sub

Sub ExitApp()

    Activity.Finish
   
    ExitApplication   
   
End Sub

The code works great and it properly launches the devices SMS app and all the user has to do is click the "SEND" button in the devices SMS app.

But if the SMS app is still being displayed on the device's screen and I simply click the devices "HOME" button to return to the homescreen, then try clicking on my app's icon to run my app again, the SMS app's UI will reappear - NOT my app's UI. I have to click the devices back-button to "close" the SMS app, then when I click my app's icon, my app's UI will properly appear.

I verified that my app does properly end and unload from memory right after it invokes the intent.

So, why does using an Intent in this way prevent my app's UI from displaying again unless I "close" the SMS app using the back-button or a task manager before trying to run my app again?
 

JohnC

Expert
Licensed User
I think that did it...

You're a genius!
 
Upvote 0
Top