Android的短信API [英] Android SMS API

查看:395
本文介绍了Android的短信API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道短信内容提供商是不公开的API(至少没有记录)的一部分,但如果我理解正确的话,它仍然可以使用很多短信的功能,只要你知道如何使用API​​( ?)。

I know that the SMS content provider is not part of the public API (at least not documented), but if I understand correctly it's still possible to use many of the SMS features as long as you know how to use the API(?).

例如,它是pretty的简单的插入短信到您的收件箱:

E.g it's pretty straightforward to insert an SMS into your inbox:

 ContentValues values = new ContentValues();
 values.put("address", "+457014921911"); 
 contentResolver.insert(Uri.parse("content://sms"), values);

不幸的是这不会触发标准的新短信在你的收件箱的通知。是否可以手动触发呢?

Unfortunately this does not trigger the standard "new-SMS-in-your-inbox" notification. Is it possible to trigger this manually?

修改:AFAIK标准的邮件应用程序(信息),在Android正在监听使用android.permission.RECEIVE_SMS允许传入的短信。然后,当一个新的SMS已经来临,状态栏通知被插入与一个特殊的通知标识。 所以,一个解决方案(上述)我的问题可能是找到,并发送正确的广播意图;像新短信已经到来-intent。

Edit: AFAIK the "standard mail application (Messaging)" in Android is listening for incoming SMSes using the android.permission.RECEIVE_SMS permission. And then, when a new SMS has arrived, a status bar notification is inserted with a "special" notification id. So one solution to my problem (stated above) could be to find, and send the correct broadcast intent; something like "NEW SMS HAS ARRIVED"-intent.

修改:下载的第三方消息传递应用程序( chompsms )从Android Market 。这个应用程序满足了我的需求更好。当我执行code以上的chompsms发现新的短信,并显示标准状态栏通知。所以,我要说的是,标准的Andr​​oid信息应用程序不能正确检测到的短信?还是我错了?

Edit: Downloaded a third party messaging application (chompsms) from Android market. This application satisfies my needs better. When i execute the code above the chompsms notice the new sms and shows the "standard status bar notification". So I would say that the standard Android Messaging application is not detecting sms properly? Or am I wrong?

推荐答案

不幸的是,code负责这些通知是隐藏在的消息传递应用程序。类<一href="http://android.git.kernel.org/?p=platform/packages/apps/Mms.git;a=blob_plain;f=src/com/android/mms/transaction/MessagingNotification.java;hb=b0e1b6b529e9aaaca69b48d721bf06f8a4c3aa76"相对=nofollow> MessagingNotification 有一个静态方法 updateAllNotifications ,你可以调用使用 PathClassLoader 与反思:

Unfortunately the code responsible for these notifications is hidden in the messaging application. The class MessagingNotification has a static method updateAllNotifications that you could call using a PathClassLoader and reflection:

PathClassLoader c = new PathClassLoader("/system/app/Mms.apk", getClassLoader());
Class.forName("com.android.mms.util.ContactInfoCache", true, c)
    .getMethod("init", Context.class).invoke(null, context);
Class.forName("com.android.mms.transaction.MessagingNotification", true, c)
    .getMethod("updateAllNotifications", Context.class).invoke(null, context);

显然是一个的非常糟糕的主意有以下几个原因,但我想不出另一种方法做你描述。

This is obviously a very bad idea for several reasons but I can't think of another way to do what you described.

这篇关于Android的短信API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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