Android ";从「;通过tmomail.net发送的sms的标记
它显示从电子邮件服务发送的消息的真实“发件人”标记。7135192435@tmomail.net有一个不同的“From”标签,然后在通过SMS接收消息后,消息详细信息会显示什么。我希望能够通过tmomail.net接收短信息,但缺少的链接恰恰是手机所看到的“发件人”标签。 我成功地接收到了其他手机的短信,我的广播接收器捕捉到了它们。但是,我无法正确设置“发件人”过滤器,以便通过tmomail.net接收这些文本。提前感谢所有诺贝尔奖安卓奇才,他们可能会从项目中抽出时间来提供帮助。下面是代码Android ";从「;通过tmomail.net发送的sms的标记,android,sms,broadcast,mms,intercept,Android,Sms,Broadcast,Mms,Intercept,它显示从电子邮件服务发送的消息的真实“发件人”标记。7135192435@tmomail.net有一个不同的“From”标签,然后在通过SMS接收消息后,消息详细信息会显示什么。我希望能够通过tmomail.net接收短信息,但缺少的链接恰恰是手机所看到的“发件人”标签。 我成功地接收到了其他手机的短信,我的广播接收器捕捉到了它们。但是,我无法正确设置“发件人”过滤器,以便通过tmomail.net接收这些文本。提前感谢所有诺贝尔奖安卓奇才,他们可能会从项目中抽出时间来提供帮助。下面是代码 pu
public class SmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// ---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
Log.d("SMS_Project", "Beginning fired!");
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]);
String mFrom = msgs[i].getOriginatingAddress();
String mBody = msgs[i].getMessageBody().toString();
Log.d("SMS_Project", "The From tag follows this line");
if (mFrom.equals("JimJohanson@JollyRanchers.com")) {
Log.d("SMS_Project", "above is the from tag");
if (mBody.indexOf("1") == 0) {
str += "SMS from '" + mFrom + "'";
str += " :";
str += mBody;
str += "\n";
// ---display the new SMS message---
Log.d("SMS_Project", "Toast anyone?");
Toast.makeText(context, str, Toast.LENGTH_LONG).show();
this.abortBroadcast();
}
}
}
}
Log.d("SMS_Project", "No toast yet");}
公共类SmsReceiver扩展了BroadcastReceiver{
@凌驾
公共void onReceive(上下文、意图){
//---获取传入的SMS消息---
Bundle=intent.getExtras();
SmsMessage[]msgs=null;
字符串str=“”;
Log.d(“SMS_项目”,“开始开火!”);
if(bundle!=null){
//---检索收到的短信---
Object[]pdus=(Object[])bundle.get(“pdus”);
msgs=新SMS消息[PDU.length];
对于(int i=0;i
舱单信息:
<receiver android:name=".SmsReceiver" >
<intent-filter android:priority="99999999" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
以下是我的权限:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
我怀疑问题在于手机无法将电子邮件翻译成合法的短信。也许它是一种多媒体信息类型?在我开始之前,我将不停地搜索蓝色。如果您对我目前的内容有任何疑问,请告诉我。谢谢。我将尝试通过mFrom字符串a进行检查其他遇到此Im的人的nd Log.d //插入
Log.d("SMS_Project", mFrom);
//就在上面
(mFrom.equals("JimJohanson@JollyRanchers.com"))
希望这能给我一个准确一致的“from”标记以获得结果。真不敢相信我花了这么长时间才想出这样一个简单的测试。提示:对于复制/粘贴专业以上的任何人来说,学习如何正确调试和使用LogCat都是必要的。好吧,不管我过去的所有抓人行为……这个问题的答案是使用getEmailFrom()函数 例如:
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
String mFrom = msgs[i].getOriginatingAddress();
String mBody = msgs[i].getMessageBody().toString();
String mEmail = msgs[i].getEmailFrom().toString();
*Boolean mSomething = msgs[i].isEmail();*
Log.d("SMS_Project_From", mFrom);
Log.d("SMS_Project_mBody", mBody);
*Log.d("SMS_Project_Email", mEmail);*
这包括Logcat,以便您可以准确地识别电子邮件的来源。没有其他人遇到过这样的问题?以下无法通过这些方法完成…地址是四位数…例如4208、3906、4287、4152。显然,TMail会将其路由到随机数目的服务器,并吐出不可预测的nu参数。