title: Can't open an activity in android
body: <p>I have some problems with android programming. I am trying to open an activity on my phone, but it fails. It says unfortunately the program has stopped. I do not know how to solve this, I try to connect from this method below. Any help is appreciated. Please ask if I did not specify enough.</p>
  
  <pre><code>    public void addGlossary(View v){
      Intent intent = new Intent (this, addGlossary.class);
      Button buttonZero = (Button) findViewById(R.id.buttonZero);
      startActivity(intent);
  
  }
  </code></pre>
  
  <p>Here is the code for the activity:</p>
  
  <pre><code>public abstract class addGlossary extends Activity implements OnClickListener, OnInitListener {
  
  
      private int MY_DATA_CHECK_CODE = 0;
  
  
     private TextToSpeech myTTS;
  
  
  private MediaPlayer mMediaPlayer;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_add_glossary);
  
  
          Button speakButton = (Button)findViewById(R.id.speak);
          speakButton.setOnClickListener(this);
  
  
          Intent checkTTSIntent = new Intent();
          checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
          startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE);
          mMediaPlayer = new MediaPlayer();
          mMediaPlayer = MediaPlayer.create(this, R.raw.button);
          mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
          mMediaPlayer.start();
          mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
              @Override
              public void onCompletion(MediaPlayer mp) {
                  mMediaPlayer.stop();
              }
          });
  
  
      }
  
      public void buttonReturn(View v){
          Intent intent = new Intent (this, MainActivity.class);
          Button buttonreturn = (Button) findViewById(R.id.buttonReturn);
          startActivity(intent);
  
      }
  
  
      public void startGame(View v){
          Intent intent = new Intent (this, firstLevel.class);
          Button buttonstart = (Button) findViewById(R.id.buttonStart);
          startActivity(intent);
  
  
  
      }
  
  
  
  
      public void onInit(int initStatus) {
          if(myTTS.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE) {
              myTTS.setLanguage(Locale.US);
          }
  
          else if (initStatus == TextToSpeech.ERROR) {
              Toast.makeText(this, "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show();
          }
  
      }
  
  
      private void speakWords(String speech){
          myTTS.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
  
  
  
          }
  
      public void buttonAdd(){
          //lagrar texten från textfältet man knappade in till string
          EditText enteredText = (EditText)findViewById(R.id.enter);
          String words = enteredText.getText().toString();
          speakWords(words);
  
      }
  
  
  
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          if (requestCode == MY_DATA_CHECK_CODE) {
              if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
                  myTTS = new TextToSpeech(this, this);
              }
              else {
                  Intent installTTSIntent = new Intent();
                  installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                  startActivity(installTTSIntent);
              }
          }
      }
  
  
      @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_add_glossary, 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);
      }
  }
  </code></pre>