Getting sms while phone is asleep
<p>I have an app that receives sms (via BroadCastReceiver) and starts an Activity to handle incoming sms (including playing a sound to notify user, updating database and showing a message to user). </p>

<p>The problem is that sometimes that app is not running and mobile is asleep, I receive nothing but as soon as I unlock screen, I got 4 or 5 messages together!</p>

<p>EDIT:
Definition of BroadcastReceiver:</p>

<pre><code>    &lt;receiver
        android:name=".util.sms.SmsReceiver"
        android:enabled="true" &gt;
        &lt;intent-filter android:priority="999" &gt;
            &lt;action android:name="android.intent.action.DATA_SMS_RECEIVED" /&gt;
            &lt;data android:scheme="sms" /&gt;
            &lt;data android:port="56790" /&gt;
        &lt;/intent-filter&gt;
    &lt;/receiver&gt;
</code></pre>

<p>Definition of my Activity:</p>

<pre><code>    &lt;activity
        android:name=".MyActivity"
        android:launchMode="singleInstance"&gt;
    &lt;/activity&gt;
</code></pre>

<p>Inside Activity:</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
            // ...
            handleNewMessage(this.getIntent());
    }


@Override
public void onNewIntent (Intent intent) {
    super.onNewIntent(intent);
    handleNewMessage(intent);       
}
</code></pre>

<p>Starting MyActivity from BroadcastReceiver:</p>

<pre><code>@Override
public void onReceive(Context context, Intent intent) {
        //...
        if( smsIsMine() ) {
    Intent intent = new Intent();
    intent.putExtra("MESSAGE_BODY", sms.getBody());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setClass(context, MyActivity.class);
    context.startActivity(intent);                
        }
    }
</code></pre>

<p>Any idea?</p>
