Android 如何为SMS号码添加比较检查

Android 如何为SMS号码添加比较检查,android,python,python-2.7,android-intent,python-3.x,Android,Python,Python 2.7,Android Intent,Python 3.x,我需要在此代码中添加一个检查,以查找sms是否来自BroadcastReceive的OnReceive方法上的所需/所需号码。您可以使用下面的代码查找发件人 import android droid = android.Android() SMSmsgs = droid.smsGetMessages(False, 'inbox').result for message in SMSmsgs: print 'From: '+message['address']+' > '+m

我需要在此代码中添加一个检查,以查找sms是否来自BroadcastReceive的OnReceive方法上的所需/所需号码。您可以使用下面的代码查找发件人

import android 
droid = android.Android() 
SMSmsgs = droid.smsGetMessages(False, 'inbox').result 
for message in SMSmsgs: 
    print 'From: '+message['address']+' > '+message['body']+'\n'
public void onReceive(上下文、意图){
//---获取传入的SMS消息---
Bundle=intent.getExtras();
SmsMessage[]msgs=null;
Object[]pdus=(Object[])bundle.get(“pdus”);
msgs=新SMS消息[PDU.length];
对于(int i=0;i
我需要python语言
public void onReceive(Context context, Intent intent) {
    //---get the SMS message passed in---
        Bundle bundle = intent.getExtras();
        SmsMessage[] msgs = null;
        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 sender = msgs[i].getOriginatingAddress();
            // Your logic here to find the match
        }
}