Android发送和监听正在发送的短信

问题描述 投票:0回答:1

到目前为止,这就是我所拥有的。然而,客户现在想知道短信是否确实已发送,并且在单击发送按钮后,他们希望返回到应用程序。

如何监听短信是否已发送?它会在活动 onActivityResult() 中吗? 您如何告诉短信客户端在发送后退出? 我只需要制作自己的发送短信的屏幕,然后直接发送短信而无需启动短信应用程序吗?

    public static void launchSMSIntent(String to, String body, Context context)
    {
        Intent smsIntent = new Intent(Intent.ACTION_VIEW);
        smsIntent.setType("vnd.android-dir/mms-sms");
        if(to != null)
            smsIntent.putExtra("address", to);
        if(body != null)
            smsIntent.putExtra("sms_body", body);
        ((Activity)context).startActivityForResult(smsIntent, Constants.SMS_INTENT);
    }
java android sms
1个回答
2
投票

如果您需要监听正在发送的短信,您需要通过 android.telephony.SMSManager api 自行完成。无法保证用户使用的任何随机短信应用程序都会返回一个标志来告诉您它是否已发送。

© www.soinside.com 2019 - 2024. All rights reserved.