使用Intent发送短信后回到我的应用程序 [英] Getting back to my application after sending sms using intent
问题描述
我一直在寻找这个,发现有很多关于这个的线程.但是事情对我不起作用.尝试设置"exit_on_sent",还尝试使用startAcitivityForResult.这是我尝试使用的代码段
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);
推荐答案
我的要求是在发送消息后返回到我的应用程序.
My requirement is to go back to my application after sending message.
当您使用ACTION_SENDTO
或ACTION_VIEW
或其他Intent
操作时,您正在启动第三方应用程序以执行某些操作.在这种情况下,您正在启动第三方应用程序以发送SMS消息.
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.
正在使用约20亿个Android设备,分布在约10,000个设备模型中.在这些设备型号中,将有数十种(甚至数百种)不同的预装SMS客户端.也欢迎用户从Play商店或其他应用分发渠道安装其他SMS客户端.
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.
当您的应用程序启动这数百个SMS客户端之一时,会发生什么情况取决于这些SMS客户端的开发人员,而不是您.
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.
如果您想控制整个用户体验,请使用SmsManager
自己发送SMS消息,如 Ankit指出的一个>.如果要使用用户首选的SMS客户端,请坚持使用ACTION_SENDTO
,但是此时发生的情况取决于SMS客户端开发人员和用户,而不是您自己.
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.
这篇关于使用Intent发送短信后回到我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!