title: Showing a Toast in Text To Speech if not Supported
body: <p>When adding Toast to TTS button in Fragement , i get this error <strong>"Cannot resolve method 'getApplicationContext()"</strong> even i tried <code>getActivty()</code>. and <code>getContext()</code>. , then more errors showed up,this is the toast :</p>
  
  <p><strong>Toast.makeText(getApplicationContext(), "Not Supported", Toast.LENGTH_SHORT).show();</strong></p>
  
  <p>Here is the fragement code :</p>
  
  <pre><code>  TextToSpeech toSpeech;
      int result;
      EditText editText;
      String text;
  
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.fragment_home, container, false);
  
  
          editText = v.findViewById(R.id.editText);
  
          toSpeech = new TextToSpeech(HomeFragment.this, new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int status) {
                  if (status == TextToSpeech.SUCCESS) {
                      Locale locale = new Locale("tr-TR");
                      int result = toSpeech.setLanguage(locale);
                  } else {
                      Toast.makeText(getApplicationContext(), "Not Supported", Toast.LENGTH_SHORT).show(); 
                  }
              }
          });
  
  
          return v;
      }
  
      public void TTS(View view) {
          switch (view.getId()) {
              case R.id.bplay:
                  if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                  } else {
                      text = editText.getText().toString();
                      toSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null);
                      toSpeech.setSpeechRate((float) 0.8);
                      toSpeech.setPitch((float) 0.7);
  
                  }
                  break;
          }
      }
  
      @Override
      public void onDestroy() {
          super.onDestroy();
          if (toSpeech != null) ;
          {
              assert toSpeech != null;
              toSpeech.stop();
              toSpeech.shutdown();
          }
  
      }
  
  }
  </code></pre>