title: Application crashes on selecting spinner item?
body: <p>In my application, I'm providing various <code>Templates</code> for the <code>Text Message Body</code>, as <code>spinner list items</code> , that can be selected and user can send them instead of typing <code>message</code>, But the problem is when user open the menu item to select template the <code>application crashes</code>. <code>Spinner</code> i've put in <code>alert dialog box</code> which is accessible through menu item. </p>
  
  <p><strong>Code for dialog box *</strong></p>
  
  <pre><code>AlertDialog.Builder rdialog = new AlertDialog.Builder(MainActivity.this);
              rdialog.setTitle("Select Message");
              rdialog.setIcon(android.R.drawable.ic_input_get);
              LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
              alertView = inflater.inflate(R.layout.rptsetting,null);
  
              final Spinner fSpinner = (Spinner)alertView.findViewById(R.id.fSpinner);
              String providers[] ={"Busy", "Good Morning", "In office"};
              ArrayAdapter&lt;String&gt; adp = new ArrayAdapter&lt;String&gt; (MainActivity.this,android.R.layout.simple_spinner_dropdown_item,providers);
              fSpinner.setAdapter(adp);
              fSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
  
                  @Override
                  public void onItemSelected(AdapterView&lt;?&gt; aparent, View arg1,
                          int pos, long arg3) {
  
                      String selectedItem = fSpinner.getSelectedItem().toString();
                      if(selectedItem.equals("Busy")){
                          body = "Currently Busy call again later, Thanks";
                      }
  
                      if(selectedItem.equals("Good Morning")){
                          body = "A very Good Morning, Have a nice day";
                      }
  
                      if(selectedItem.equals("In office")){
                          body = "Currently in office";
                      }   
  
                  }
  
                  @Override
                  public void onNothingSelected(AdapterView&lt;?&gt; aparent) {
                  }
              });
  rdialog.setView(alertView);
              rdialog.setNeutralButton("SUBMIT", new DialogInterface.OnClickListener() {
  
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
  
                      dialog.dismiss();   
                      }
                  });
  
              AlertDialog rdialog1 = rdialog.create();
              rdialog1.show();
  </code></pre>
  
  <p>I've define <code>body</code> as global String so that it can be accessible by <code>Sms Manager</code> to use it as body of message to be send. 
  Log Cat
  <img src="https://i.stack.imgur.com/rr7zr.png" alt="Log cat"></p>
  
  <p>Thanks in advance!</p>