clear Recent apps wipe the apps memory and my receiver stopped working
<p>MyApp's Receiver is just working fine if it in background which is:</p>

<pre><code>    public class MySmsReceiver extends WakefulBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        System.out.println("triggered sms");
        if(intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
          Toast.makeText(context, "message Received", Toast.LENGHT_SHORT).show();
    }
}
</code></pre>

<p>and my manifest file for receiver is </p>

<pre><code>        &lt;receiver android:name=".MySmsReceiver"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" /&gt;

        &lt;/intent-filter&gt;
    &lt;/receiver&gt;
</code></pre>

<p>Document says that if i declare a receiver in manifest file it should always work. but in my case it's not...</p>

<p>But whenever I clear my recent apps by swiping them it just stopped working. and after i went to taskmanager and saw that MyApps forcestop being disabled like below   <a href="https://i.stack.imgur.com/xsmZ5.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/xsmZ5.jpg" alt="screenshot of my app in taskmanager"></a></p>

<p>and i figured it out some apps like watsapp and fb always kept in memory am saying this bcoz after the swiping of clear recent apps still the task manager has the followig state like below </p>

<p><a href="https://i.stack.imgur.com/qpHvh.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/qpHvh.jpg" alt="fb state in task manager"></a></p>

<p>and <a href="https://i.stack.imgur.com/Z7VOL.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Z7VOL.jpg" alt="watsapp state in taskmanager"></a></p>

<p>How can i do this into my app.. what will made my app to behave like other thirdparty apps like watspp and facebook...how can i make my app to be in memory always I am asking this Then only My receiver will always work.. If i am wrong then give me a solution to do this...</p>

<p>I Have been searching this a lot and still i cannot find the solution... Am i asking wrong? or really is there a way to do it? Please someone help me... This making me a week!!! Hope i explained my problem here if i am not ask me I'll give you immediate response.</p>