I would like to have a SMS intent be populated for the user, then launch the intent and after the SMS is sent, return to my app to continue to execute code. So thus far I use this to setup the Intent:
Uri uri = Uri.parse("smsto:" + cellNumberEditText.getText().toString());
Intent smsIntent = new Intent(Intent.ACTION_SENDTO, uri);
smsIntent.putExtra("sms_body", smsMessageEditText.getText().toString());
smsIntent.putExtra("exit_on_sent", true);
startActivityForResult(smsIntent,1);
Note I add the Extra exit_on_sent
parameter to the intent.
Then off course I catch the onActivityResult
:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1)
{
//Do some post sending work
}
}
The problem is, after debugging, I noticed that as soon as the intent launches, the onActivityResult
fires immediately, not after the the intent closes. Furthermore, the SMS app does not close after sending even though the parameter is set. I even added android:launchMode="singleInstance"
to my Manifest.xml. What am I missing?