Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to catch SMS received with android.provider.Telephony.SMS_RECEIVED
    primarykey
    data
    text
    <p>I am not able to catch the intent when a SMS is received. Below is my code of the service. I am able to catch the "<code>Intent.ACTION_SCREEN_ON</code>" and "<code>Intent.ACTION_SCREEN_OFF</code>" but I am NOT able to catch the <code>SMS_RECEIVED</code> intent "<code>android.provider.Telephony.SMS_RECEIVED</code>".</p> <p>Sincerely appreciate any hints on what I am doing wrong here?</p> <pre><code>public class SmsCatcher extends Service{ BroadcastReceiver myBroadcast = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.i("myBroadcast SmsCatcher", "Entered onReceive method"); if(intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { Log.i("myBroadcast SmsCatcher", "Caught SCREEN_OFF"); } if(intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { Log.i("myBroadcast SmsCatcher", "Caught SCREEN_ON"); } if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) { Log.i("myBroadcast SmsCatcher", "SMS_RECEIVED"); } } }; @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { super.onCreate(); Log.i("neil SmsCatcher", "Entered onCreate() in 'SmsCatcher extends Service'"); Toast.makeText(this, "Entered onCreate() in 'SmsCatcher extends Service'", Toast.LENGTH_LONG).show(); registerReceiver(myBroadcast, new IntentFilter(Intent.ACTION_SCREEN_ON)); registerReceiver(myBroadcast, new IntentFilter(Intent.ACTION_SCREEN_OFF)); } @Override public void onDestroy() { super.onDestroy(); Log.i("neil SmsCatcher", "Entered onDestroy() in 'SmsCatcher extends Service'"); Toast.makeText(this, "Entered onDestroy() in 'SmsCatcher extends Service'", Toast.LENGTH_LONG).show(); } } </code></pre> <p><strong>UPDATE 1</strong>: Adding some more information from my ongoing debug: I used the App <a href="https://play.google.com/store/apps/details?id=lt.andro.broadcastlogger&amp;hl=en" rel="nofollow noreferrer">Internal Broadcasts Monitor</a> to see there is a broadcast when there is a text message received and I dont see anything, very strange. What could be the reason? I have other SMS apps installed (Hangout, AT&amp;T Messages) - these cant suppress the broadcast can they?</p> <p><strong>UPDATE 2: FOUND PROBLEM BUT DONT KNOW HOW TO SOLVE</strong> I uninstalled the <a href="https://play.google.com/store/apps/details?id=com.google.android.talk" rel="nofollow noreferrer">Google Hangouts (replaces Talk)</a> app and it WORKS!!! Any solution around this? (should i be opening a separate thread as per stackoverflow rules?)</p> <p><strong>UPDATE 3: FOUND ROOTCAUSE</strong> (with help below of course, thank you) It turns out that because of the new Google Hangouts App, I needed to <a href="http://developer.android.com/reference/android/content/IntentFilter.html#setPriority%28int%29" rel="nofollow noreferrer">setPriority(int)</a>. I found the solution at <a href="https://stackoverflow.com/questions/20021492/enabling-sms-support-in-hangouts-2-0-breaks-the-broadcastreceiver-of-sms-receive">Enabling SMS support in Hangouts 2.0 breaks the BroadcastReceiver of SMS_RECEIVED in my app</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload