title: How to use a broadcast receiver to receive SMS in Android Studio?
body: <p>I'm building an application that should trigger a function when an SMS is received. I've used Broadcast Receivers and NotificationListeners before, but for this specific purpose, I need to register this Broadcast receiver. At this time, I'm unable to register it, and I can't quite tell why. </p>
  
  <p>I've tried multiple answers to similar issues on stack overflow but for some reason, the <code>Log.d</code> that I'm using to troubleshoot right now will not print when I receive an SMS. I think I'm fundamentally misunderstanding the problem, although I'm not sure how. </p>
  
  <p>Here is my <code>SmsListener.java</code> class:</p>
  
  <pre><code>public class SmsListener extends BroadcastReceiver {
      private SharedPreferences preferences;
  
      @Override
      public void onReceive(Context context, Intent intent) {
          if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){
              Log.d("Test","test");
          }
      }
  }
  </code></pre>
  
  <p>Here is my Manifest:</p>
  
  <pre><code>&lt;receiver android:name=".SmsListener"&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>Here is the <code>onCreate()</code> function of my activity that should be calling it:</p>
  
  <pre><code>BroadcastReceiver br = new SmsListener();
  IntentFilter filter = new IntentFilter(Telephony.Sms.Intents.SMS_RECEIVED_ACTION);
  registerReceiver(br,filter);
  </code></pre>
  
  <p>Thank you any help. I'm at a total loss.</p>