title: Android Studio getApplicationcontext()
body: <p>I am trying to have messages pop up if the user does not enter their username and password, however my problem is the getApplicationcontext(), it says "cannot resolve method". how do i fix it?-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</p>
  
  <pre><code>package com.example.rojean.prelim_project;
  
  import android.support.v7.app.AppCompatActivity;
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  public class LoginActivity extends AppCompatActivity {
  
      Button loginBtn;
      EditText txtUsername, txtPassword;
      AccountsManagement session;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
  
          Object getApplication;
          session = new AccountsManagement(getApplicationcontext());
  
          txtUsername = (EditText) findViewById(R.id.nameField);
          txtPassword = (EditText) findViewById(R.id.passwordField);
  
          Toast.makeText(getApplicationContext(),
                  "User Login Status: " + session.isUserLoggedIn(),
                  Toast.LENGTH_LONG).show();
  
          loginBtn = (Button)findViewById(R.id.loginBtn);
          loginBtn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  String username = txtUsername.getText().toString();
                  String password = txtPassword.getText().toString();
  
                  //Validation method
                  if(username.trim().length() &gt; 0 &amp;&amp; password.trim().length() &gt; 0){
                      // For testing puspose username, password is checked with static data
                      // username = admin
                      // password = admin
  
                      if(username.equals("admin") &amp;&amp; password.equals("admin")){
  
                          // Creating user login session
                          // Statically storing name="Android Example"
                          // and email="androidexample84@gmail.com"
                          session.createUserLoginSession("Android Example",
                                  "androidexample84@gmail.com");
  
                          // Starting MainActivity
                          Intent i = new Intent(getApplicationContext(), MainActivity.class);
                          i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
                          // Add new Flag to start new Activity
                          i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                          startActivity(i);
  
                          finish();
                      }else{
  
                          // username / password doesn't match&amp;
                          Toast.makeText(getApplicationContext(),
                                  "Username/Password is incorrect",
                                  Toast.LENGTH_LONG).show();
                      }
                  }else{
  
                      // user didn't entered username or password
                      Toast.makeText(getApplicationContext(),
                              "Please enter username and password",
                              Toast.LENGTH_LONG).show();
  
                  }
              }
          });
      }
  
  }
  </code></pre>