I added a phone verification sms feature to the registration process of my app but the sms is written as sent and received in the SMS inbox. At the moment I only send a simple text just to verify the number so nothing secret here but it's not so user friendly so I was wondering if I could somehow prevents this SMS to be written.
I added abortBroadcast(); if the code is correct but it had no effect. I'm using Android 4.4.2 and I've read that for security reasons, there is no way to do that so is there a way to achieve what I want maybe in a different way? I know other apps do manage to do so...
The code for sending SMS:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(Utils.phone, null, "text", null, null);
The code for consuming thr SMS:
public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[]) bundle.get("pdus");
SmsMessage messages = SmsMessage.createFromPdu((byte[]) pdus[0]);
if (messages.getMessageBody().contains("text")) {
Toast.makeText(Utils.context,"ok",Toast.LENGTH_LONG).show();
abortBroadcast();
}
}
}
This is the manifest:
<receiver android:name="com.tomerapp.tomerapp.utils.SMSReceiver" android:exported="false">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
Does android:exported="false" means the receiver/my app will only catch SMSs sent from the app itself? I don't want to waste battery for SMSs other than what the app sends.