以编程方式在 android 8 上发送短信

progmatically send sms on android 8

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

 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

有数百种不同的应用程序可能会以 smsto: Uri 响应 ACTION_SENDTO

I want the SMS screen to be dismissed AND control to come to my app automatically after sending the SMS

SMS 客户端做什么由SMS 客户端的开发人员决定。而且,同样,有数百个。

i'm using this code to send sms

sms_bodyexit_on_sent 都没有记录 Intent ACTION_SENDTO 的额外内容。只有数百个 SMS 客户端中的一些会兑现它们。

but in android 8 when i click send my application goes on background

该 SMS 客户端的开发人员不遵守 exit_on_sent,或者没有测试该案例。

如果您想完全控制 SMS-sending 体验,请使用 SmsManager 自行发送。否则,请理解您正在启动数百个可能的应用程序中的任何一个,这些应用程序将执行其开发人员想要的任何操作。