在Android 8上以编程方式发送短信 [英] progmatically send sms on android 8
问题描述
我希望关闭SMS屏幕,并希望在发送SMS后自动进入我的应用程序. 我正在使用此代码发送短信:
I want the SMS screen to be dismissed AND control to come to my app automatically after sending the SMS. i'm using this code to send sms:
Uri uri = Uri.parse("smsto:" + "074********; 074********");
Intent smsSIntent = new Intent(Intent.ACTION_SENDTO, uri);
smsSIntent.putExtra("sms_body", "iconference sms");
sendIntent.putExtra("exit_on_sent", true);
startActivity(smsSIntent);
此代码在所有版本的android上均可正常运行,但在android 8中,当我单击发送"时,我的应用程序将在后台运行 你能帮我吗?
this code works fine in all versions of android but in android 8 when i click send my application goes on background can you help me ?
推荐答案
此代码在所有版本的android上都能正常工作
this code works fine in all versions of android
有数百种可能用smsto:
Uri
响应ACTION_SENDTO
的应用程序.
There are hundreds of different apps that might respond to ACTION_SENDTO
with an smsto:
Uri
.
我希望关闭SMS屏幕,并希望在发送SMS后自动进入我的应用程序
I want the SMS screen to be dismissed AND control to come to my app automatically after sending the SMS
SMS客户端执行的操作取决于SMS客户端的开发人员.而且,还有数百个.
What the SMS client does is up to the developers of the SMS client. And, again, there are hundreds of those.
我正在使用此代码发送短信
i'm using this code to send sms
sms_body
和exit_on_sent
均未记录ACTION_SENDTO
的Intent
附加内容.在数百个SMS客户端中,只有一些会尊敬他们.
Neither sms_body
nor exit_on_sent
are documented Intent
extras for ACTION_SENDTO
. Only some of of the hundreds of SMS clients will honor them.
但是在android 8中,当我单击发送"时,我的应用程序将在后台运行
but in android 8 when i click send my application goes on background
该SMS客户端的开发人员不尊重exit_on_sent
,或者未测试该情况.
The developers of that SMS client do not honor exit_on_sent
, or didn't test that case.
如果要绝对控制SMS发送体验,请使用SmsManager
自己发送.否则,请了解您正在启动数百种可能的应用程序中的任何一种,并且这些应用程序将执行开发人员想要的任何事情.
If you want absolute control over the SMS-sending experience, send it yourself, using SmsManager
. Otherwise, please understand that you are starting any one of hundreds of possible apps, and those apps will do whatever their developers want.
这篇关于在Android 8上以编程方式发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!