title: button.onclick() causes "Unfortunately xxx has stopped working
body: <p>Newbie to Android. Trying to make simple SMS text messenger(for higher purpose) based on example from Web. Code below. Phone is S4 mini (API19). 
  System works(text msg properly sent) when "sendSMSmessage()" is called as part of onCreate. As soon as I try to set the onClick interrupt - the code response (on the phone) "Unfortunately xxx has stopped working". Tried extend activity and AppCompatActivity (as indicated with comments). Missing some kind of setup / reference for the onClick method call? Thanks for your help.</p>
  
  <pre><code>package com.example.tas_pb_usr1.ArtSafe;
  
  import android.app.Activity;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.telephony.SmsManager;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.Toast;
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  
  //public class MainActivity extends AppCompatActivity {
      public class MainActivity extends Activity {
  //    Button sendBtn = (Button) findViewById(R.id.Sms_send_button);
       Button sendBtn;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
         kkBtnSetup();
            sendSMSMessage();
  }
      protected void sendSMSMessage() {
          Log.i("Send SMS", "");
  /*        String phoneNo = txtphoneNo.getText().toString();
          String message = txtMessage.getText().toString();*/
  
          String phoneNo = "1234567";
          String currentDateTimeString = DateFormat.getDateTimeInstance().toString();
          Calendar c = Calendar.getInstance();
          SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          String formattedDate = df.format(c.getTime());
          String message = "Some SMS text   " +  formattedDate;
  
          try {
              SmsManager smsManager = SmsManager.getDefault();
              smsManager.sendTextMessage(phoneNo, null, message, null, null);
              Toast.makeText(getApplicationContext(), "SMS sent.", Toast.LENGTH_LONG).show();
          }
  
          catch (Exception e) {
              Toast.makeText(getApplicationContext(), "SMS faild, please try again.", Toast.LENGTH_LONG).show();
              e.printStackTrace();
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      public void kkBtnSetup(){
          sendBtn.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  sendSMSMessage();
              }
          });
      }
  
  
  }
  </code></pre>
  
  <p>Here is layout:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"&gt;
  
      &lt;TextView android:text="@string/hello_world" android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/textView" /&gt;
  
      &lt;Button
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Send SMS"
          android:id="@+id/Sms_send_button"
          android:layout_below="@+id/textView"
          android:layout_toEndOf="@+id/textView"
          android:layout_marginTop="93dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>