0

I have an app that has default SMS app permissions. So I can receive SMS only using system default Receiver:

 <receiver
        android:name="com.socialproof.smad_gateway.logic.receivers.MyDefaultSmsReceiver"
        android:permission="android.permission.BROADCAST_SMS">
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_DELIVER" />
        </intent-filter>
    </receiver>

And Receiver's code:

  public class MyDefaultSmsReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle intentExtras = intent.getExtras();

        if (intentExtras != null) {
          //read and manage received SMS
        }
    }
  }

Everything works good but I noticed that received SMS by my receiver are not stored in original Message app(check when I give back default SMS app permission to Meassaging app). Also when I try to loop within received SMS, I get no SMS received in my app (only those received by original Messaging app), I'm using this code:

  private void testSmsLoop() {
    Uri smsUri = Uri.parse("content://sms");
    Cursor cursorOldSms = App.getUniversalContext().getContentResolver().query(smsUri, null, null, null, null);

    if (cursorOldSms != null) {
        Log.d("TAG", "rows: " + cursorOldSms.getCount());

        while (cursorOldSms.moveToNext()) {
           //handle looped SMS
        }

        cursorOldSms.close();
    }
}

So is this an expected behavior?

I'am asking because I'd like to delete all SMS after it's received to ignore the full memory case (now it seems they are not stored even)

Choletski
  • 7,074
  • 6
  • 43
  • 64

0 Answers0