I am try to read incoming sms that I sent to the user. I saw a lots of answers around the internet but I can't make it work.
This is my manifest with the permissions and the Receiver:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<application>
...
<receiver android:name=".notifications.receiver.SmsCodeReader"
android:permission="android.permission.BROADCAST_SMS"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
And this is my Receiver class:
public class SmsCodeReader extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "received something", Toast.LENGTH_SHORT).show();
}
}
I am working on API 22 so no need run-time permission, but no matter what I try I cant make the Receiver to work. I didn't get any exception or error in the log
EDIT: If I send Broadcast with Intent like this:
Intent in = new Intent("android.provider.Telephony.SMS_RECEIVED");
sendBroadcast(in);
I can see the Toast. so it's mean the Broadcast is properly registered in the manifest. So, why it doesn't work with real SMS?
Thanks to all