title: Cannot resolve method getApplication()
body: <p>I created an Android global variable in my App and when I try to access it in my activitys with getApplication I get the Error: </p>
  
  <blockquote>
    <p>Cannot resolve method getApplication()</p>
  </blockquote>
  
  <p>My code in the class that extends Application:</p>
  
  <pre><code>    package com.example.user.app;
  
      import android.app.Application;
  
  
      public class answer extends Application {
  
             private String answer1;
  
              public String getSomeVariable() {
                   return answer1;
                }
  
              public void setanswer1(String one) {
                  this.answer1 = one;
                  }
          }
  </code></pre>
  
  <p>My code in the activity:</p>
  
  <pre><code>       package com.example.user.pilz_app;
  
         import android.content.Intent;
         import android.support.design.widget.FloatingActionButton;
         import android.support.design.widget.Snackbar;
         import android.support.v7.app.AppCompatActivity;
         import android.os.Bundle;
         import android.support.v7.widget.Toolbar;
         import android.view.View;
         import android.widget.ImageButton;
  
         public class QuestionOne extends AppCompatActivity {
  
               @Override
                    protected void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.activity_question_one);
  
              ImageButton half = findViewById(R.id.half);
              half.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
              Intent intent = new Intent(QuestionOne.this, QuestionTwo.class);
              startActivity(intent);
             ((answer) this.getApplication()).setanswer1("half");
             }
  
         });
  </code></pre>