title: how to get application context from non activity and finish();?
body: <p>here is my code:</p>
  
  <p>this is the HomeActivity.java:</p>
  
  <pre><code>public class HomeActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          session = new SessionManagement(getApplicationContext());
          session.checkLogin();
  </code></pre>
  
  <p>This is the SessionManagement.java:</p>
  
  <pre><code>public class SessionManagement {
      SharedPreferences pref;
  
      // Editor for Shared preferences
      SharedPreferences.Editor editor;
  
      // Context
      Context _context;
  
      public void checkLogin(){
          // Check login status
          if(!this.isLoggedIn()){
  
              // user is not logged in redirect him to Login Activity
              Intent i = new Intent(_context, LoginActivity.class);
              // Closing all the Activities
              i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
              // Add new Flag to start new Activity
              i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
              // Staring Login Activity
              _context.startActivity(i);
          }
  
      }
  }
  </code></pre>
  
  <p>I am trying to call "finish();" inside this: <strong>public void checkLogin(){ if(!this.isLoggedIn()){</strong> so i can close/finish(); the HomeActivity.java class.</p>
  
  <p>how can i do that?</p>