Android的广播接收器发送SMS消息? [英] Android Broadcast Receiver for Sent SMS messages?

查看:414
本文介绍了Android的广播接收器发送SMS消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个的BroadcastReceiver 并用 android.provider.Telephony.SMS_RECEIVED 动作过滤器配置它,所以它是所谓的每次电话的接收的文本。

I created a BroadcastReceiver and configured it with an android.provider.Telephony.SMS_RECEIVED action filter so it is called everytime the phone receives a text.

有没有一些事件/操作或其它方式为我的应用程序能够获知每当电话的发送的文本(pferably独立发送它的应用程序$ P $)?

Is there some event/action or other way for my application to be notified whenever the phone sends a text (preferably independent of the application that sends it)?

到目前为止,我看到的唯一的选择就是轮询内容提供商内容://短信/发送这竟然不给我所有已发送的文本,因为应用程序可以选择不把它放在那里。

So far the only option I see is to poll the content provider for content://sms/sent which doesn't even give me all sent texts because applications can choose not to put it there.

推荐答案

不幸的是,(目前)没有办法实施<一个href="http://developer.android.com/reference/android/content/BroadcastReceiver.html"><$c$c>BroadcastReceiver因为标准短信应用程序使用<一个href="http://developer.android.com/reference/android/telephony/gsm/SmsManager.html"><$c$c>SmsManger发送邮件,但指定了具体的内部类的发送和传递意图( SmsReceiver.class和 MessageStatusReceiver.class 分别为 )。不,这是任何安慰,但你可以找到在SMS应用程序下面的注释<一href="http://android.git.kernel.org/?p=platform/packages/apps/Mms.git;a=blob%5Fplain;f=src/com/android/mms/transaction/SmsMessageSender.java;hb=HEAD">source:

Unfortunately there is (currently) no way to implement a BroadcastReceiver because the standard sms application uses a SmsManger to send the messages but specifies concrete internal classes for the sent and delivered intents (SmsReceiver.class and MessageStatusReceiver.class respectively). Not that it is any consolation but you can find the following comment in the Sms application's source:

// TODO: Fix: It should not be necessary to
// specify the class in this intent.  Doing that
// unnecessarily limits customizability.

最好的选择似乎是轮询内容://短信/发送,可能使用<一个href="http://developer.android.com/reference/android/database/ContentObserver.html"><$c$c>ContentObserver.

The best alternative seems to be polling content://sms/sent, potentially using a ContentObserver.

这篇关于Android的广播接收器发送SMS消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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