-1

由于发送的短信没有广播接收器,我们需要定期轮询短信内容提供者(content://sms/sent),并想出一个方法来捕捉消息已发送(onChange)。这是最容易的部分!

棘手的一点是,是否有可能(可能是一个巧妙的技巧、黑客攻击、解决方法,甚至是现有系统中的漏洞)可以指示用户是手动发送短信还是由其他安装的应用程序自动发送的由某种意图触发的后台服务或接收器!

说啥?可能的?

4

1 回答 1

0

如果您的应用程序正在发送短信,那么您可以获得短信发送或未发送的状态,如下所示。由于您没有未发送短信的全球回呼,您无法了解它。

    /**
 * Listen to Delivery Reports of sent SMSs
 */
private BroadcastReceiver mSmsDeliveryListener = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        try{
            int result = getResultCode();
            switch (result){
                case Activity.RESULT_OK:
                    //SMS Delivered
                    break;

                case Activity.RESULT_CANCELED:
                case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                case SmsManager.RESULT_ERROR_NO_SERVICE:
                case SmsManager.RESULT_ERROR_NULL_PDU:
                case SmsManager.RESULT_ERROR_RADIO_OFF:
                    //SMS Delivery failed
                    break;

                default:
        //SMS Delivery failed
                    break;
                }

            }//End of Switch
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
};
于 2012-04-26T14:19:04.253 回答