Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

android - Getting back to my application after sending sms using intent

I have been searching for this, found many threads specifying on this. But things are not working for me. Tried setting "exit_on_sent" and also tried using startAcitivityForResult. Here is the code snippet I was trying with

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("smsto:" + phoneNumbers)); // phoneNumbers is a list of phone numbers to which i need to send messages at the same time
sendIntent.putExtra("sms_body", context.getResources().getString(R.string.message_body));
sendIntent.putExtra("exit_on_sent", true);
context.startActivity(sendIntent);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My requirement is to go back to my application after sending message.

When you use ACTION_SENDTO, or ACTION_VIEW, or other Intent actions, you are launching a third-party app to go do something. In this case, you are launching a third-party app to send an SMS message.

There are ~2 billion Android devices in use, spread across ~10,000 device models. There will be dozens, if not hundreds, of different pre-installed SMS clients across those device models. Users are also welcome to install other SMS clients from the Play Store or other app distribution channels.

What happens when your app starts up one of those hundreds of SMS clients is up to the developers of those SMS clients, not you.

If you want control over the entire user experience, send the SMS message yourself, using SmsManager, as Ankit pointed out. If you want to use the user's preferred SMS client, stick with ACTION_SENDTO, but what happens at that point is up to the SMS client developers and the user, not you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...