1

Here is the code:

AndroidManifest.xml

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />


    <receiver
        android:name=".SmsListener"
        android:exported="true" android:enabled="true">
        <intent-filter android:priority="2147483647" >
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            <action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
        </intent-filter>
    </receiver>

Just a simple "SmsListener" as follows:

public class SmsListener extends BroadcastReceiver {


@Override
public void onReceive(Context context, Intent intent) {

    if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
        Bundle bundle = intent.getExtras();   

Also requesting permissions at run time is set as well and application is granted with required permissions.

 if(ContextCompat.checkSelfPermission(context, "android.permission.READ_SMS") == PackageManager.PERMISSION_GRANTED) {

I tested on most of the devices (iOS as well) it works fine but seems Android 6.0 ignores BroadcastReceiver and "onReceive" does not get triggered.

When I change Default Messaging app from "Messages" to "Hangouts" or "Messenger" then onReceive gets triggered.

enter image description here

Any idea why Android 6.0 and above acts like this?

arlen
  • 1,065
  • 1
  • 16
  • 31
  • All required permissions are granted to the application but still no result. – arlen Nov 28 '16 at 17:37
  • @arlen, although they were granted, you still need to ask user with these permissions. – Anggrayudi H Nov 28 '16 at 17:38
  • I did through the code on my application and still it doesn't work on Android 6.0 and above but when I change Default Messaging app from "Messages" to "Hangouts" or "Messenger" then "onReceive" gets triggered. – arlen Nov 28 '16 at 17:41
  • 1
    Which device are you changing the default app on? The sender, or the receiver? – Mike M. Nov 28 '16 at 18:19
  • Receiver device, the device which my app is installed. – arlen Nov 28 '16 at 19:04
  • 1
    Are the devices you're testing on all on the same carrier? If so, which one? T-Mobile, maybe? Or possibly AT&T? Are you certain the messages your app is missing are being delivered as SMS? I.e., when you [query your SMS inbox](http://stackoverflow.com/questions/848728/how-can-i-read-sms-messages-from-the-inbox-programmatically-in-android), are those missed messages there? – Mike M. Nov 28 '16 at 19:47
  • T-Mobile, I will try to query Sms inobx to see those messages there or missing and let you know. – arlen Nov 28 '16 at 20:27
  • 1
    Given that you're on T-Mobile, and the messages don't appear in the SMS Provider, then I would have to guess that they might actually be RCS, which will not fire your SMS Receiver. http://stackoverflow.com/questions/38044406/sms-missing-from-content-provider-results-on-android-marshmallow – Mike M. Nov 28 '16 at 23:21
  • Seems the problem is Samsung devices with Android 6.0 and above with T-Mobile carrier. – arlen Nov 28 '16 at 23:35

0 Answers0