- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在开发一个应用程序,它将所有传入和传出的短信存储在 SD 卡中的文本文件中。
我可以使用广播接收器收听传入的消息。我发现很难收听传出的短信。
我在某种程度上知道需要设置已发送箱或发件箱上的内容观察器,但我不知道该怎么做。
如何做到这一点?
最佳答案
基本上,你必须注册一个内容观察者......像这样:
ContentResolver contentResolver = context.getContentResolver();
contentResolver.registerContentObserver(Uri.parse("content://sms/out"),true, yourObserver);
yourObserver
是一个对象 (new YourObserver(new Handler())
),可能如下所示:
class YourObserver extends ContentObserver {
public YourObserver(Handler handler) {
super(handler);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
// save the message to the SD card here
}
}
那么,您究竟是如何获得短信内容的呢?您必须使用 Cursor
:
// save the message to the SD card here
Uri uriSMSURI = Uri.parse("content://sms/out");
Cursor cur = this.getContentResolver().query(uriSMSURI, null, null, null, null);
// this will make it point to the first record, which is the last SMS sent
cur.moveToNext();
String content = cur.getString(cur.getColumnIndex("body"));
// use cur.getColumnNames() to get a list of all available columns...
// each field that compounds a SMS is represented by a column (phone number, status, etc.)
// then just save all data you want to the SDcard :)
关于android - 在 Android 中收听传出的短信或已发送的邮箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5808577/
我想创建一个 Mercurial Hook ,当我推送到本地存储库时,它会推送到备份远程存储库。我以为我可以钩住“传出”钩子(Hook),但这会创建一个不漂亮的无限循环。那么是否有类似推送后的 Hoo
我有一个托管在 Tomcat 上的应用程序,它需要通过 IBM DataPower 设备对托管的服务进行 HTTPS 调用。我在日志中看到以下内容: http-bio-8080-exec-1, REA
是否有一个 hg 命令可以组合 hg传入 + hg传出 + hg status? 这会告诉您是否有任何远程内容需要传入,是否有任何本地提交的内容需要出去,或者是否有任何本地更改需要提交。 最佳答案 虽
我在 Azure 中有一个 Windows VM,用于 VS2015 实验。 Google 云端硬盘无法联系更新服务器来完成其自身的安装(尽管 Chrome/Omaha 工作正常)。 显然,我也无法通
我正在使用 QuickFIX/J (1.6.4)。我可以看到所有消息都非常正确地隔离(传入/传出/事件) , event> (Session FIX.4.2:CLIENT2/SUB-> sched
我在 Azure 中有一个 Windows VM,用于 VS2015 实验。 Google 云端硬盘无法联系更新服务器来完成其自身的安装(尽管 Chrome/Omaha 工作正常)。 显然,我也无法通
我正在使用 QuickFIX/J (1.6.4)。我可以看到所有消息都非常正确地隔离(传入/传出/事件) , event> (Session FIX.4.2:CLIENT2/SUB-> sched
我正在使用 docker-compose 运行我的应用程序。该应用程序包含许多容器。一个容器有一个 node.js 应用程序,另一个容器有一个 .net 核心应用程序。当尝试从任何容器向外部服务器发送
我想将文件从 HDFS 传输到不在 hadoop 集群中但在网络中的不同服务器的本地文件系统。 我本可以做到: hadoop fs -copyToLocal and then scp/ftp .
我遇到了一个奇怪的偶然事件,我的结果 lsof | grep 40006 制作 java 29722 appsrv 54u IPv6 71135755
我错误地 checkin 了一些更改。现在更改正在传出更改中,但我不希望它们交付。我怎样才能让它们回到 Unresolved 状态?如果我丢弃它们,它们就会从我的源代码中消失,我就会失去我的工作。 最
我在将 URL 参数添加到每个生成的 URL 或重定向到 ASP MVC 4 应用程序时遇到问题。 我想生成一个 ID,并在整个应用程序的任何时候使用这个 ID。在 session 中存储 id 不是
我正在开发一个 Java/Spring Web 应用程序,它对每个传入请求执行以下操作: 向第三方网络服务器发出大量请求, 检索每个人的响应, 将每个响应解析为 JSON 对象列表, 将 JSON 对
我有一个基本的“包装器”WinForms 应用程序,它有一些基本控件和一个 WebBrowser 控件 (System.Windows.Forms.WebBrowser)。这链接到一个网络服务,它完成
这个问题在这里已经有了答案: Can I send webrequest from specified ip address with .NET Framework? (3 个答案) 关闭 8 年前
我在这项研究中对交通路口进行研究,我试图找到有影响力的节点,也就是说......哪些路口会相互影响,我试图将我的网络表示为图形网络,所以我搜索了已经使用的算法在希望将同样的方法应用于我的问题的网络中,
我正在开发 OpenCL 1.2 处理大型图像的应用程序。 目前,我正在测试的图像是 16507x21244 像素。我的 内核在一个循环中运行,该循环对图像的 block 进行操作.内核将 32bpp
我知道有关断开链接的问题一直被问到,但我的问题似乎有点不同,而且没有一个解决方案有效。 现在,点击我的导航部分中的其他网站链接时,它们都不起作用。它记录它们在那里,如果您右键单击它并选择“在新选项卡中
我正在使用 node.js 构建数据传输代理服务器。它使用 http(s) REST API 将客户端请求通过管道传输到快速对象存储服务器。 It works fine for the individ
我有一个 Azure Servicebus 函数触发器,每当事件放入其指定队列时,该触发器就会调用外部端点。但是,当函数拾取事件并准备发出传出请求时,它会失败并显示以下日志消息 Executed 'A
我是一名优秀的程序员,十分优秀!