在 android 8 上以编程方式发送短信 [英] progmatically send sms on android 8

查看:34
本文介绍了在 android 8 上以编程方式发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在发送短信后关闭短信屏幕并控制自动进入我的应用程序.我正在使用此代码发送短信:

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.

我希望在发送短信后关闭短信屏幕并控制自动进入我的应用

I want the SMS screen to be dismissed AND control to come to my app automatically after sending the 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_bodyexit_on_sent 都没有记录 Intent 用于 ACTION_SENDTO 的额外内容.数百个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆