title: I get error in spinner selected value
body: <p>I'm trying to make an app to send messages with default or user predefined messages and phone numbers I will put here my code</p>
  
  <pre><code> private static final int MY_PERMISSIONS_REQUEST_SEND_SMS = 0;
  String phoneNo, message;
  List&lt;String&gt; pn, txt;
  Spinner sp1, sp2;
  Button b, b1, b2, b3, b4;
  EditText et, et1;
  
  ArrayAdapter&lt;String&gt; adp1, adp2;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      setupSpinners();
  
      b = (Button) findViewById(R.id.button);
      b1 = (Button) findViewById(R.id.button1);
      b2 = (Button) findViewById(R.id.button2);
      b3 = (Button) findViewById(R.id.button3);
      b4 = (Button) findViewById(R.id.button4);
      et = (EditText) findViewById(R.id.editText);
      et1 = (EditText) findViewById(R.id.editText1);
  
      b.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              adp1.add(et.getText().toString());
              et.setText(null);
          }
  
      });
  
      b2.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              adp2.add(et1.getText().toString());
              et1.setText(null);
          }
  
      });
  }
  
  public void setupSpinners() {
  
      sp1 = (Spinner) findViewById(R.id.spinner);
      sp2 = (Spinner) findViewById(R.id.spinner1);
      pn = new ArrayList&lt;String&gt;();
      txt = new ArrayList&lt;String&gt;();
      txt.add("Sorry Boss I'cant go today i'm sick");
      pn.add("123456789");
  
      adp1 = new ArrayAdapter&lt;String&gt;(this,
              android.R.layout.simple_dropdown_item_1line, pn);
      adp2 = new ArrayAdapter&lt;String&gt;(this,
              android.R.layout.simple_dropdown_item_1line, txt);
  
      sp1.setAdapter(adp1);
      sp1.setSelection((pn.size() - 1));
      sp2.setAdapter(adp2);
      sp2.setSelection((txt.size() - 1));
  
      sp1.setOnItemSelectedListener(new OnItemSelectedListener() {
  
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
              sp1.setSelection(arg2);
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          }
  
  
      });
      sp2.setOnItemSelectedListener(new OnItemSelectedListener() {
  
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
              sp2.setSelection(arg2);
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
  
              b4.setOnClickListener(new View.OnClickListener() {
                  public void onClick(View view) {
                      sendSMSMessage();
                  }
  
                  protected void sendSMSMessage() {
                      phoneNo =  sp1.getSelectedItem().toString();
                      message =  sp2.getSelectedItem().toString();
  
                      if (ContextCompat.checkSelfPermission(this,
                              Manifest.permission.SEND_SMS)
                              != PackageManager.PERMISSION_GRANTED) {
                          if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                                  Manifest.permission.SEND_SMS)) {
                          } else {
                              ActivityCompat.requestPermissions(this,
                                      new String[]{Manifest.permission.SEND_SMS},
                                      MY_PERMISSIONS_REQUEST_SEND_SMS);
                          }
                      }
                  }
  
                  @Override
                  public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
                      switch (requestCode) {
                          case MY_PERMISSIONS_REQUEST_SEND_SMS: {
                              if (grantResults.length &gt; 0
                                      &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                                  SmsManager smsManager = SmsManager.getDefault();
                                  smsManager.sendTextMessage(phoneNo, null, message, null, null);
                                  Toast.makeText(getApplicationContext(), "SMS sent.",
                                          Toast.LENGTH_LONG).show();
                              } else {
                                  Toast.makeText(getApplicationContext(),
                                          "SMS faild, please try again.", Toast.LENGTH_LONG).show();
                                  return;
                              }
                          }
                      }
  
                  }
              });
          }
      });
  }
  </code></pre>
  
  <p>The part where it gives the error is the (this,</p>
  
  <pre><code>if (ContextCompat.checkSelfPermission(this,
  Manifest.permission.SEND_SMS)
  != PackageManager.PERMISSION_GRANTED) {
  if (ActivityCompat.shouldShowRequestPermissionRationale(this,
   Manifest.permission.SEND_SMS)) {
  } else {
  ActivityCompat.requestPermissions(this,
  new String[]{Manifest.permission.SEND_SMS},
  MY_PERMISSIONS_REQUEST_SEND_SMS);
  </code></pre>
  
  <p>I need help to know how to select the spinner selected value to send trough text. </p>