I have an application which should watching incoming SMS (scan SMS text and show toast messages based on content) , even after my application is closed. The desired functionality is app watching all incoming SMS until app will not moved from device, and now it works like this. But I think, if I will need soon, to “switch of” this “watching eye”, how I could to do this?
public class SmsReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
if (bundle != null)
{
//do some action
}
}
BroadcastReceiver’s code is a separate unit SMSReceiver.java. From main Activity I do not call this receiver, do not register and do not unregister. It’s just working independently. Amazing.
So.. how I can ti stop this receiver??
You’ll have to take the
BroadcastReceiverout of your Manifest to control it such as using it in aServiceorActivity. When its in the Manifest its always on.