title: want a TOAST on sms receive in android studio
body: <p>i am designing a app which will deisplay a toast with its content. i am using android studio and virtual device as lolipop api 21. please help.</p>
  
  <p><a href="https://drive.google.com/open?id=0B4QdgVVRYfIsQlU4eWlrNmtfQVk&amp;authuser=0" rel="nofollow">MANIFEST_file</a> and
  <a href="https://drive.google.com/open?id=0B4QdgVVRYfIsRDlZUExrOElHOG8&amp;authuser=0" rel="nofollow">CODE</a></p>
  
  <p>My code is : </p>
  
  <pre><code>    package com.example.vaibhav;
    import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
   import android.os.Bundle;
   import android.telephony.SmsMessage;
   import android.util.Log;
   import android.widget.Toast;
  public class SMSReceiver extends BroadcastReceiver  {
      SmsManager sms = SmsManager.getDefault();
  
      public void onReceive(Context context, Intent intent) {
  
         // Retrieves a map of extended data from the intent.
         final Bundle bundle = intent.getExtras();
  
         try {
  
          if (bundle != null) {
  
              final Object[] pdusObj = (Object[]) bundle.get("pdus");
  
              for (int i = 0; i &lt; pdusObj.length; i++) {
  
                  SmsMessage currentMessage =                                                                                    
                   SmsMessage.createFromPdu((byte[]) pdusObj[i]);
                  String phoneNumber = 
                  currentMessage.getDisplayOriginatingAddress();
  
                  String senderNum = phoneNumber;
                  String message = currentMessage.getDisplayMessageBody();
  
                  // Show Alert
                  int duration = Toast.LENGTH_LONG;
                  Toast toast = Toast.makeText(context,
                          "senderNum: " + senderNum + ", message: " + message, 
                    duration);
                  toast.show();
  
              } // end for loop
          } // bundle is null
  
           } catch (Exception e) {
               Log.e("SmsReceiver", "Exception smsReceiver" + e);
          }
  
  
        }
          }
  </code></pre>
  
  <p>MY Manifest . xml file is:</p>
  
  <pre><code>    &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.vaibhav"
      android:versionCode="1"
      android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="4"
          android:targetSdkVersion="21"
          /&gt;
      &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;&lt;/uses- 
        permission&gt;
      &lt;uses-permission android:name="android.permission.read_sms"&gt;&lt;/uses-
        permission&gt;
      &lt;uses-permission android:name="android.permission.hardware_test"/&gt;
      &lt;application android:allowBackup="true" android:label="@string/app_name"
          android:icon="@mipmap/ic_launcher" android:theme="@style/AppTheme"&gt;
          &lt;receiver android:name=".SMSReceiver"&gt;
              &lt;intent-filter&gt;
                  &lt;action 
       android:name="android.provider.Telephony.SMS_RECEIVED"/&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
      &lt;/application&gt;
  
      &lt;/manifest&gt;
  </code></pre>
  
  <p>i am getting error on line 10.
  Error:(10, 5) error: cannot find symbol class SmsManager
  Error:(10, 22) error: cannot find symbol variable SmsManager</p>