The best thing you need to do is debug your code, you have hard coded the phone number in a format that may or may not occur, make sure in what format your receiver phone number appears? When I was working over it I was sending message over 0333xxx-xxxx
number and I was receiving as +92xxx
. But it's not sure for all, different telecommunication companies may use different format, for that you should use
if(number.equals("+92333xxx-xxxxx"))
or better use a contains
, that would actually make it more appropriate to match the number and remove the possibility of format error
if(number.contains("333xxx-xxxxx")){
// Your code to abort message
}
Hope this helps