вот мой onReceive()
метод, он работает:)
public void onReceive( Context context, Intent intent ) {
// get incoming message
Bundle extras = intent.getExtras();
String messages = "";
// if message available, go on
if ( extras != null ) {
// get the array of the message
Object[] smsExtra = (Object[]) extras.get( "pdus" );
// loop through the number of available messages
for ( int i = 0; i < smsExtra.length; ++i ) {
// create smsmessage from raw pdu
SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);
// retrieve contents of message
String body = sms.getMessageBody().toString();
String address = sms.getOriginatingAddress();
// only accept messages from specified number
if(address.equals(0000)){
// store the message to database
storeToDatabase( contentResolver, sms );
// stop message from getting to default app
this.abortBroadcast();
}
}
}
}