title: Receive new SMS in Same Activity
body: <p>I want to receive new <code>SMS</code> in same activity.
  For that i tried following code. Can anyone tell me what is wrong in my code?</p>
  
  <p><strong>My Code:</strong></p>
  
  <pre><code>public BroadcastReceiver mReceiver = new BroadcastReceiver() {
  
          @Override
          public void onReceive(Context context, Intent intent) {
              Log.i("LOG", "message recived");
  
          }
      };
  @Override
      protected void onResume() {
          super.onResume();
          IntentFilter intentFilter = new IntentFilter();
          intentFilter.addAction("android.provider.Telephony.SMS_RECEIVED");
          registerReceiver(mReceiver, intentFilter);
      }
  
      @Override
      protected void onPause() {
          super.onPause();
          unregisterReceiver(this.mReceiver);
      }
  </code></pre>
  
  <p>And in <code>Manifest</code> file add this permission :</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;
  </code></pre>
  
  <p>thank you in advance.</p>