Alright, I have tried every solution on Stack and nothing works.My current method registers the \"SmsListener\" receiver from the MainActivity. All I\'m trying to do is initiali
After spending more than an hour I found that RECEIVE_SMS
permission is required.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.RECEIVE_SMS},
MY_PERMISSIONS_REQUEST_SMS_RECEIVE);
Prioirty is not required to be set. This should work.
Found a solution.
First make another app your default SMS app.
Then: Google Hangout --> Settings (Disable merged conversations) --> SMS (Disable SMS)
You are registering broadcast
your in your Activity
, so it won't work if your app is in background. you can remove this from your Activity
and you can register it in Manifest.
ex:
<receiver android:name=".SmsListener">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
Along with this add permission to recieve sms.
Try this, and it will work
Try following way with highest reading priority value,
<receiver android:name=".SmsListener"
android:enabled="true"
android:exported="true"
android:permission="android.permission.READ_SMS">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
This will surely solve out your problem.
Update from below comment,
Since you are checking on Android version 6.0.1 just follow these steps,