我想覆蓋默認的android消息傳遞應用程序。 如果我收到短信或彩信,我希望將其發送給電子郵件,但我不想在電話上發送任何通知。 所以基本上我想更換默認的消息應用程序。覆蓋默認的android消息傳遞應用程序
如何讓我的應用程序成爲接收短信的默認應用程序?
非常感謝。這正是我需要的。但我還有一個問題。 我使用接收器來獲取消息......但我不知道如何在手機中查找消息並將其標記爲已讀。
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
str += "SMS from " + msgs[i].getOriginatingAddress();
str += " :";
str += msgs[i].getMessageBody().toString();
str += "\n";
}
//---display the new SMS message---
Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
//---find and mark the messages as read---
Uri uriSms = Uri.parse("content://sms/inbox/");
try{
Cursor c = context.getContentResolver().query(uriSms, null,null,null,null);
//---code to find the message by body and sender---
...
}
有沒有什麼方法可以識別消息就像一個ID? 現在我發現郵件比較收件箱中所有郵件的bofy和發件人號碼。
感謝, 拉杜
鏈接不再可用... – 2012-04-26 17:27:26
@MartinBories感謝您的支持!我用一個正在工作的人取而代之。 – 2012-04-27 13:42:47