Android 5.0.2 - SMS Broadcast Receiver - can not get it working
<p>I am testing on Xiaomi Redmi Note 3 and what I need is very simple:
* Register broadcast receiver for incoming text messages
* Once message comes in, just read it</p>

<p>It looks like I can not get receiver register no matter what I try.</p>

<p>From the google docs, since 4.4 there should be no way for any app to swallow the event and every app listening should get a chance to get the event.</p>

<p>I have tried all kind of combinations and googled pretty much everything. Could it be the Xiaomi phone issue?</p>

<p>Here is my manifest:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.com.dimitar.test"
    android:versionCode="1"
    android:versionName="1.0" &gt;

    &lt;uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="21" /&gt;

    &lt;uses-permission
        android:name="android.permission.RECEIVE_SMS"
        android:protectionLevel="dangerous" /&gt;

    &lt;application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" &gt;

        &lt;receiver
            android:name="com.example.com.dimitar.test.SmsListener"
            android:enabled="true" &gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" /&gt;
            &lt;/intent-filter&gt;
        &lt;/receiver&gt;

        &lt;activity
            android:name=".MainActivity"
            android:label="@string/app_name" &gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;

                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;
</code></pre>

<p>Java code:</p>

<pre><code> package com.example.com.dimitar.test;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;

public class SmsListener extends BroadcastReceiver{

    private SharedPreferences preferences;

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Bundle bundle = intent.getExtras();

         Toast toast = Toast.makeText(context, "poruka: ", Toast.LENGTH_SHORT);
        toast.show();

        if(bundle != null){
            //---get the SMS message passed in---
            SmsMessage[] msgs = null;
            String msg_from;
            if (bundle != null){
                //---retrieve the SMS message received---
                try{
                    Object[] pdus = (Object[]) bundle.get("pdus");
                    msgs = new SmsMessage[pdus.length];
                    for(int i=0; i&lt;msgs.length; i++){
                        msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
                        msg_from = msgs[i].getOriginatingAddress();
                        String msgBody = msgs[i].getMessageBody();


                        Toast toast1 = Toast.makeText(context, "poruka: " + msgBody, Toast.LENGTH_SHORT);
                        toast1.show();
                    }
                }catch(Exception e){
//                            Log.d("Exception caught",e.getMessage());
                }
            }
        }
    }
}
</code></pre>