I am developing an sms text blocking app for android. I have set up my app to be considered the default sms app, but I don't want to have to develop the UI and systems to handle being a messaging app myself. Does anyone know a way to pass the texts to the original messaging app once I have determined I want it to go through?
For reference, here is my code for deciding whether to block an SMS:
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[]) bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i], (String)bundle.get("format"));
long phone = PersistentData.convertNumberToLong(messages[i].getDisplayOriginatingAddress());
if(PersistentData.contactsContains(phone)){
if(PersistentData.contactByNumber(phone).getAllowedBy() < 1){
// Block
}
else{
// Allow
}
}
else if(PersistentData.callContactsContains(phone)){
if(PersistentData.callContactByNumber(phone).getAllowedBy() < 1){
// Block
}
else{
// Allow
}
}
else{
// Block
}
}
}
This receiver is set up to receive based on
<receiver android:name=".SMSReceiver"
android:permission="android.permission.BROADCAST_SMS"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_DELIVER" />
</intent-filter>
</receiver>