title: Why is my toast working with so many different contexts?
body: <p>I'm working in my activity4.java and the code is:</p>
  
  <pre><code>public class Activity4 extends Activity {
  Spinner spinner;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_4);
      spinner=findViewById(R.id.spinner);
  
      spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
              if(Activity4.this==adapterView.getContext())
              Toast.makeText(adapterView.getContext(),adapterView.getSelectedItem().toString(),Toast.LENGTH_LONG).show();
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; adapterView) {
  
          }
      });
  }
  }
  </code></pre>
  
  <p>I used adapterView.getContext() as context in the above code. But even if I replace it with getApplicationContext() like  </p>
  
  <p>Toast.makeText(getApplicationContext(),adapterView.getSelectedItem().toString(),Toast.LENGTH_LONG).show();</p>
  
  <p>or if I write getBaseContext() like this,</p>
  
  <pre><code>Toast.makeText(getBaseContext(),adapterView.getSelectedItem().toString(),Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>The toast seems to work just fine. Why is it so?</p>